mirror of https://github.com/docker/compose.git
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:
commit
2b8fa9934e
|
@ -39,9 +39,6 @@ const (
|
||||||
RestartPolicyRunAlways = "always"
|
RestartPolicyRunAlways = "always"
|
||||||
)
|
)
|
||||||
|
|
||||||
// RestartPolicyList all available restart policy values
|
|
||||||
var RestartPolicyList = []string{RestartPolicyRunNo, RestartPolicyRunAlways, RestartPolicyOnFailure}
|
|
||||||
|
|
||||||
// Container represents a created container
|
// Container represents a created container
|
||||||
type Container struct {
|
type Container struct {
|
||||||
ID string
|
ID string
|
||||||
|
|
|
@ -53,6 +53,9 @@ type Opts struct {
|
||||||
HealthTimeout time.Duration
|
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
|
// ToContainerConfig convert run options to a container configuration
|
||||||
func (r *Opts) ToContainerConfig(image string) (containers.ContainerConfig, error) {
|
func (r *Opts) ToContainerConfig(image string) (containers.ContainerConfig, error) {
|
||||||
if r.Name == "" {
|
if r.Name == "" {
|
||||||
|
@ -124,7 +127,7 @@ var restartPolicyMap = map[string]string{
|
||||||
func toRestartPolicy(value string) (string, error) {
|
func toRestartPolicy(value string) (string, error) {
|
||||||
value, ok := restartPolicyMap[value]
|
value, ok := restartPolicyMap[value]
|
||||||
if !ok {
|
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
|
return value, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue