Merge pull request #889 from gtardif/run_restart_flags_move

Minor refactoring: Move list of run specific flags where it’s used
This commit is contained in:
Nicolas De loof 2020-11-09 10:25:50 +01:00 committed by GitHub
commit 2b8fa9934e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -39,9 +39,6 @@ const (
RestartPolicyRunAlways = "always"
)
// RestartPolicyList all available restart policy values
var RestartPolicyList = []string{RestartPolicyRunNo, RestartPolicyRunAlways, RestartPolicyOnFailure}
// Container represents a created container
type Container struct {
ID string

View File

@ -53,6 +53,9 @@ type Opts struct {
HealthTimeout time.Duration
}
// RestartPolicyList all available restart policy values
var RestartPolicyList = []string{containers.RestartPolicyRunNo, containers.RestartPolicyRunAlways, containers.RestartPolicyOnFailure}
// ToContainerConfig convert run options to a container configuration
func (r *Opts) ToContainerConfig(image string) (containers.ContainerConfig, error) {
if r.Name == "" {
@ -124,7 +127,7 @@ var restartPolicyMap = map[string]string{
func toRestartPolicy(value string) (string, error) {
value, ok := restartPolicyMap[value]
if !ok {
return "", fmt.Errorf("invalid restart value, must be one of %s", strings.Join(containers.RestartPolicyList, ", "))
return "", fmt.Errorf("invalid restart value, must be one of %s", strings.Join(RestartPolicyList, ", "))
}
return value, nil
}