mirror of
https://github.com/docker/compose.git
synced 2025-07-21 04:34:38 +02:00
check that the pull policy provided is a valid one
or is not missing when --pull is used Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
This commit is contained in:
parent
af87f10650
commit
b92981015e
@ -19,6 +19,7 @@ package compose
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"slices"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@ -138,6 +139,9 @@ func (opts createOptions) GetTimeout() *time.Duration {
|
|||||||
|
|
||||||
func (opts createOptions) Apply(project *types.Project) error {
|
func (opts createOptions) Apply(project *types.Project) error {
|
||||||
if opts.pullChanged {
|
if opts.pullChanged {
|
||||||
|
if !opts.isPullPolicyValid() {
|
||||||
|
return fmt.Errorf("invalid --pull option %q", opts.Pull)
|
||||||
|
}
|
||||||
for i, service := range project.Services {
|
for i, service := range project.Services {
|
||||||
service.PullPolicy = opts.Pull
|
service.PullPolicy = opts.Pull
|
||||||
project.Services[i] = service
|
project.Services[i] = service
|
||||||
@ -187,3 +191,9 @@ func (opts createOptions) Apply(project *types.Project) error {
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (opts createOptions) isPullPolicyValid() bool {
|
||||||
|
pullPolicies := []string{types.PullPolicyAlways, types.PullPolicyNever, types.PullPolicyBuild,
|
||||||
|
types.PullPolicyMissing, types.PullPolicyIfNotPresent}
|
||||||
|
return slices.Contains(pullPolicies, opts.Pull)
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user