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
19
19
import (
20
20
"context"
21
21
"fmt"
22
+ "slices"
22
23
"strconv"
23
24
"strings"
24
25
"time"
@@ -138,6 +139,9 @@ func (opts createOptions) GetTimeout() *time.Duration {
138
139
139
140
func (opts createOptions ) Apply (project * types.Project ) error {
140
141
if opts .pullChanged {
142
+ if ! opts .isPullPolicyValid () {
143
+ return fmt .Errorf ("invalid --pull option %q" , opts .Pull )
144
+ }
141
145
for i , service := range project .Services {
142
146
service .PullPolicy = opts .Pull
143
147
project .Services [i ] = service
@@ -187,3 +191,9 @@ func (opts createOptions) Apply(project *types.Project) error {
187
191
}
188
192
return nil
189
193
}
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