mirror of
https://github.com/containers/podman.git
synced 2025-10-18 11:42:55 +08:00
Revert "compat,build: pull must accept string"
This reverts commit 5b148a0a68360892f57603b77e73c69e32fb7b7e. 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 https://github.com/containers/podman/issues/17778#issuecomment-1673931925 Signed-off-by: Matej Vasek <mvasek@redhat.com>
This commit is contained in:
@ -121,7 +121,7 @@ func BuildImage(w http.ResponseWriter, r *http.Request) {
|
|||||||
OSVersion string `schema:"osversion"`
|
OSVersion string `schema:"osversion"`
|
||||||
OutputFormat string `schema:"outputformat"`
|
OutputFormat string `schema:"outputformat"`
|
||||||
Platform []string `schema:"platform"`
|
Platform []string `schema:"platform"`
|
||||||
Pull string `schema:"pull"`
|
Pull bool `schema:"pull"`
|
||||||
PullPolicy string `schema:"pullpolicy"`
|
PullPolicy string `schema:"pullpolicy"`
|
||||||
Quiet bool `schema:"q"`
|
Quiet bool `schema:"q"`
|
||||||
Registry string `schema:"registry"`
|
Registry string `schema:"registry"`
|
||||||
@ -580,19 +580,8 @@ func BuildImage(w http.ResponseWriter, r *http.Request) {
|
|||||||
pullPolicy = buildahDefine.PolicyMap[query.PullPolicy]
|
pullPolicy = buildahDefine.PolicyMap[query.PullPolicy]
|
||||||
} else {
|
} else {
|
||||||
if _, found := r.URL.Query()["pull"]; found {
|
if _, found := r.URL.Query()["pull"]; found {
|
||||||
switch strings.ToLower(query.Pull) {
|
if query.Pull {
|
||||||
case "false":
|
|
||||||
pullPolicy = buildahDefine.PullIfMissing
|
|
||||||
case "true":
|
|
||||||
pullPolicy = buildahDefine.PullAlways
|
pullPolicy = buildahDefine.PullAlways
|
||||||
default:
|
|
||||||
policyFromMap, foundPolicy := buildahDefine.PolicyMap[query.Pull]
|
|
||||||
if foundPolicy {
|
|
||||||
pullPolicy = policyFromMap
|
|
||||||
} else {
|
|
||||||
utils.BadRequest(w, "pull", query.Pull, fmt.Errorf("invalid pull policy: %q", query.Pull))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -546,8 +546,8 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error {
|
|||||||
// (As of version 1.xx)
|
// (As of version 1.xx)
|
||||||
// - in: query
|
// - in: query
|
||||||
// name: pull
|
// name: pull
|
||||||
// type: string
|
// type: boolean
|
||||||
// default:
|
// default: false
|
||||||
// description: |
|
// description: |
|
||||||
// Attempt to pull the image even if an older image exists locally
|
// Attempt to pull the image even if an older image exists locally
|
||||||
// (As of version 1.xx)
|
// (As of version 1.xx)
|
||||||
@ -1453,8 +1453,8 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error {
|
|||||||
// (As of version 1.xx)
|
// (As of version 1.xx)
|
||||||
// - in: query
|
// - in: query
|
||||||
// name: pull
|
// name: pull
|
||||||
// type: string
|
// type: boolean
|
||||||
// default:
|
// default: false
|
||||||
// description: |
|
// description: |
|
||||||
// Attempt to pull the image even if an older image exists locally
|
// Attempt to pull the image even if an older image exists locally
|
||||||
// (As of version 1.xx)
|
// (As of version 1.xx)
|
||||||
|
@ -234,11 +234,6 @@ t POST "build?dockerfile=containerfile" $CONTAINERFILE_TAR application/json 200
|
|||||||
response_headers=$(cat "$WORKDIR/curl.headers.out")
|
response_headers=$(cat "$WORKDIR/curl.headers.out")
|
||||||
like "$response_headers" ".*application/json.*" "header does not contain application/json"
|
like "$response_headers" ".*application/json.*" "header does not contain application/json"
|
||||||
|
|
||||||
# Build api response header must contain Content-type: application/json
|
|
||||||
t POST "build?dockerfile=containerfile&pull=never" $CONTAINERFILE_TAR application/json 200
|
|
||||||
response_headers=$(cat "$WORKDIR/curl.headers.out")
|
|
||||||
like "$response_headers" ".*application/json.*" "header does not contain application/json"
|
|
||||||
|
|
||||||
# PR #12091: output from compat API must now include {"aux":{"ID":"sha..."}}
|
# PR #12091: output from compat API must now include {"aux":{"ID":"sha..."}}
|
||||||
t POST "build?dockerfile=containerfile" $CONTAINERFILE_TAR 200 \
|
t POST "build?dockerfile=containerfile" $CONTAINERFILE_TAR 200 \
|
||||||
'.aux|select(has("ID")).ID~^sha256:[0-9a-f]\{64\}$'
|
'.aux|select(has("ID")).ID~^sha256:[0-9a-f]\{64\}$'
|
||||||
|
Reference in New Issue
Block a user