78 lines
1.6 KiB
Go
78 lines
1.6 KiB
Go
package probe
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
)
|
|
|
|
const (
|
|
FlagProbePortName = "probe-port"
|
|
FlagLoggingConfigFilePathName = "logging-config-path"
|
|
)
|
|
|
|
var (
|
|
ContainerBinFileName = map[ContainerType]string{
|
|
ContainerDiscovery: "container_discovery",
|
|
ContainerNetwork: "container_network",
|
|
ContainerGeneral: "container_general.jar",
|
|
}
|
|
ContainerLoggingConfigFileName = map[ContainerType]string{
|
|
ContainerDiscovery: "discovery.logging.json",
|
|
ContainerNetwork: "network.logging.json",
|
|
ContainerGeneral: "general.logging.xml",
|
|
}
|
|
)
|
|
|
|
type ContainerType int
|
|
|
|
const (
|
|
ContainerDiscovery ContainerType = iota
|
|
ContainerNetwork
|
|
ContainerGeneral
|
|
)
|
|
|
|
var (
|
|
containerTypeID = map[ContainerType]string{
|
|
ContainerDiscovery: "DISCOVERY",
|
|
ContainerNetwork: "NETWORK",
|
|
ContainerGeneral: "GENERAL",
|
|
}
|
|
|
|
containerTypeName = map[string]ContainerType{
|
|
"DISCOVERY": ContainerDiscovery,
|
|
"NETWORK": ContainerNetwork,
|
|
"GENERAL": ContainerGeneral,
|
|
}
|
|
)
|
|
|
|
func ToContainerType(v string) ContainerType {
|
|
return containerTypeName[v]
|
|
}
|
|
|
|
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
|
|
}
|