mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-24 09:48:49 +02:00
update validateSignal
This commit is contained in:
@@ -31,6 +31,12 @@ const (
|
|||||||
StopMethodKill StopMethod = "kill"
|
StopMethodKill StopMethod = "kill"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var validSignals = map[string]struct{}{
|
||||||
|
"": {},
|
||||||
|
"SIGINT": {}, "SIGTERM": {}, "SIGHUP": {}, "SIGQUIT": {},
|
||||||
|
"INT": {}, "TERM": {}, "HUP": {}, "QUIT": {},
|
||||||
|
}
|
||||||
|
|
||||||
func ValidateConfig(cont *docker.Container) (*Config, E.Error) {
|
func ValidateConfig(cont *docker.Container) (*Config, E.Error) {
|
||||||
if cont == nil {
|
if cont == nil {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
@@ -83,12 +89,9 @@ func validateDurationPostitive(value string) (time.Duration, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func validateSignal(s string) (Signal, error) {
|
func validateSignal(s string) (Signal, error) {
|
||||||
switch s {
|
if _, ok := validSignals[s]; ok {
|
||||||
case "", "SIGINT", "SIGTERM", "SIGHUP", "SIGQUIT",
|
|
||||||
"INT", "TERM", "HUP", "QUIT":
|
|
||||||
return Signal(s), nil
|
return Signal(s), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return "", errors.New("invalid signal " + s)
|
return "", errors.New("invalid signal " + s)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user