File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ package compose
1919import (
2020 "context"
2121 "fmt"
22+ "slices"
2223 "strconv"
2324 "strings"
2425 "time"
@@ -138,6 +139,9 @@ func (opts createOptions) GetTimeout() *time.Duration {
138139
139140func (opts createOptions ) Apply (project * types.Project ) error {
140141 if opts .pullChanged {
142+ if ! opts .isPullPolicyValid () {
143+ return fmt .Errorf ("invalid --pull option %q" , opts .Pull )
144+ }
141145 for i , service := range project .Services {
142146 service .PullPolicy = opts .Pull
143147 project .Services [i ] = service
@@ -187,3 +191,9 @@ func (opts createOptions) Apply(project *types.Project) error {
187191 }
188192 return nil
189193}
194+
195+ func (opts createOptions ) isPullPolicyValid () bool {
196+ pullPolicies := []string {types .PullPolicyAlways , types .PullPolicyNever , types .PullPolicyBuild ,
197+ types .PullPolicyMissing , types .PullPolicyIfNotPresent }
198+ return slices .Contains (pullPolicies , opts .Pull )
199+ }
You can’t perform that action at this time.
0 commit comments