watchtower/container/command_info.go
2018-05-27 20:59:53 +02:00

27 lines
No EOL
582 B
Go

package container
import (
"encoding/json"
)
type CommandInfo struct {
User string
Privileged bool
Env []string
Cmd []string
}
func ReadCommandInfoFromJSON(commandInfoJSON string) (CommandInfo, error) {
commandInfo := CommandInfo{}
err := json.Unmarshal([]byte(commandInfoJSON), &commandInfo)
if err != nil {
return CommandInfo{}, err
}
return commandInfo, nil
}
func (commandInfo CommandInfo) IsDefined() bool {
return commandInfo.Cmd != nil && len(commandInfo.Cmd) > 0
}