2018-04-26 07:37:59 +00:00
|
|
|
package probe
|
2018-04-18 08:37:18 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"fmt"
|
|
|
|
)
|
|
|
|
|
2018-04-18 11:20:43 +00:00
|
|
|
const (
|
2018-04-30 10:20:23 +00:00
|
|
|
FlagProbePortName = "probe-port"
|
2018-04-18 11:20:43 +00:00
|
|
|
FlagLoggingConfigFilePathName = "logging-config-path"
|
|
|
|
)
|
|
|
|
|
2018-04-18 11:10:29 +00:00
|
|
|
var (
|
|
|
|
ContainerBinFileName = map[ContainerType]string{
|
|
|
|
ContainerDiscovery: "container_discovery",
|
|
|
|
ContainerNetwork: "container_network",
|
2018-05-04 09:18:41 +00:00
|
|
|
ContainerGeneral: "container_general.jar",
|
2018-04-18 11:10:29 +00:00
|
|
|
}
|
|
|
|
ContainerLoggingConfigFileName = map[ContainerType]string{
|
|
|
|
ContainerDiscovery: "discovery.logging.json",
|
|
|
|
ContainerNetwork: "network.logging.json",
|
2018-05-04 09:18:41 +00:00
|
|
|
ContainerGeneral: "general.logging.xml",
|
2018-04-18 11:10:29 +00:00
|
|
|
}
|
2018-04-18 11:04:34 +00:00
|
|
|
)
|
|
|
|
|
2018-04-18 08:37:18 +00:00
|
|
|
type ContainerType int
|
|
|
|
|
|
|
|
const (
|
2018-04-18 11:04:34 +00:00
|
|
|
ContainerDiscovery ContainerType = iota
|
|
|
|
ContainerNetwork
|
2018-05-04 09:18:41 +00:00
|
|
|
ContainerGeneral
|
2018-04-18 08:37:18 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
containerTypeID = map[ContainerType]string{
|
2018-04-18 11:04:34 +00:00
|
|
|
ContainerDiscovery: "DISCOVERY",
|
|
|
|
ContainerNetwork: "NETWORK",
|
2018-05-04 09:18:41 +00:00
|
|
|
ContainerGeneral: "GENERAL",
|
2018-04-18 08:37:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
containerTypeName = map[string]ContainerType{
|
2018-04-18 11:04:34 +00:00
|
|
|
"DISCOVERY": ContainerDiscovery,
|
|
|
|
"NETWORK": ContainerNetwork,
|
2018-05-04 09:18:41 +00:00
|
|
|
"GENERAL": ContainerGeneral,
|
2018-04-18 08:37:18 +00:00
|
|
|
}
|
|
|
|
)
|
|
|
|
|
2018-04-28 13:12:16 +00:00
|
|
|
func ToContainerType(v string) ContainerType {
|
|
|
|
return containerTypeName[v]
|
|
|
|
}
|
|
|
|
|
2018-04-18 08:37:18 +00:00
|
|
|
func (ct ContainerType) String() string {
|
|
|
|
return containerTypeID[ct]
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ct ContainerType) MarshalJSON() ([]byte, error) {
|
|
|
|
value, ok := containerTypeID[ct]
|
|
|
|
if !ok {
|
|
|
|
return nil, fmt.Errorf("Invalid EnumType[%s] value", ct)
|
|
|
|
}
|
|
|
|
return json.Marshal(value)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ct ContainerType) UnmarshalJSON(b []byte) error {
|
|
|
|
var s string
|
|
|
|
err := json.Unmarshal(b, &s)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
value, ok := containerTypeName[s]
|
|
|
|
if !ok {
|
|
|
|
return fmt.Errorf("Invalid EnumType[%s] value", s)
|
|
|
|
}
|
|
|
|
ct = value
|
|
|
|
return nil
|
|
|
|
}
|