Skip to content

Commit 4cb2d48

Browse files
committed
Revert "compat,build: pull must accept string"
This reverts commit 5b148a0. Reverting to treating the `pull` query parameter as a boolean. Because of deceiving Docker API documentation it was assumed that the parameter is pull-policy, however that is not true. Docker does treat `pull` as a boolean. What is interesting is that Docker indeed accepts strings like `always` or `never` however Docekr both of these strings treat as `true`, not as pull-policy. As matter of the fact it seems there is no such a thing as pull-policy in Docker. More context containers#17778 (comment) Signed-off-by: Matej Vasek <[email protected]>
1 parent a60bafe commit 4cb2d48

File tree

3 files changed

+6
-22
lines changed

3 files changed

+6
-22
lines changed

pkg/api/handlers/compat/images_build.go

+2-13
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ func BuildImage(w http.ResponseWriter, r *http.Request) {
121121
OSVersion string `schema:"osversion"`
122122
OutputFormat string `schema:"outputformat"`
123123
Platform []string `schema:"platform"`
124-
Pull string `schema:"pull"`
124+
Pull bool `schema:"pull"`
125125
PullPolicy string `schema:"pullpolicy"`
126126
Quiet bool `schema:"q"`
127127
Registry string `schema:"registry"`
@@ -580,19 +580,8 @@ func BuildImage(w http.ResponseWriter, r *http.Request) {
580580
pullPolicy = buildahDefine.PolicyMap[query.PullPolicy]
581581
} else {
582582
if _, found := r.URL.Query()["pull"]; found {
583-
switch strings.ToLower(query.Pull) {
584-
case "false":
585-
pullPolicy = buildahDefine.PullIfMissing
586-
case "true":
583+
if query.Pull {
587584
pullPolicy = buildahDefine.PullAlways
588-
default:
589-
policyFromMap, foundPolicy := buildahDefine.PolicyMap[query.Pull]
590-
if foundPolicy {
591-
pullPolicy = policyFromMap
592-
} else {
593-
utils.BadRequest(w, "pull", query.Pull, fmt.Errorf("invalid pull policy: %q", query.Pull))
594-
return
595-
}
596585
}
597586
}
598587
}

pkg/api/server/register_images.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -546,8 +546,8 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error {
546546
// (As of version 1.xx)
547547
// - in: query
548548
// name: pull
549-
// type: string
550-
// default:
549+
// type: boolean
550+
// default: false
551551
// description: |
552552
// Attempt to pull the image even if an older image exists locally
553553
// (As of version 1.xx)
@@ -1453,8 +1453,8 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error {
14531453
// (As of version 1.xx)
14541454
// - in: query
14551455
// name: pull
1456-
// type: string
1457-
// default:
1456+
// type: boolean
1457+
// default: false
14581458
// description: |
14591459
// Attempt to pull the image even if an older image exists locally
14601460
// (As of version 1.xx)

test/apiv2/10-images.at

-5
Original file line numberDiff line numberDiff line change
@@ -234,11 +234,6 @@ t POST "build?dockerfile=containerfile" $CONTAINERFILE_TAR application/json 200
234234
response_headers=$(cat "$WORKDIR/curl.headers.out")
235235
like "$response_headers" ".*application/json.*" "header does not contain application/json"
236236

237-
# Build api response header must contain Content-type: application/json
238-
t POST "build?dockerfile=containerfile&pull=never" $CONTAINERFILE_TAR application/json 200
239-
response_headers=$(cat "$WORKDIR/curl.headers.out")
240-
like "$response_headers" ".*application/json.*" "header does not contain application/json"
241-
242237
# PR #12091: output from compat API must now include {"aux":{"ID":"sha..."}}
243238
t POST "build?dockerfile=containerfile" $CONTAINERFILE_TAR 200 \
244239
'.aux|select(has("ID")).ID~^sha256:[0-9a-f]\{64\}$'

0 commit comments

Comments
 (0)