mirror of
https://github.com/containers/podman.git
synced 2025-10-17 19:24:04 +08:00
api: add compatMode
paramenter to libpod's pull endpoint
Add a new `compatMode` parameter to libpod's pull endpoint. If set, the streamed JSON payload is identical to the one of the Docker compat endpoint and allows for a smooth integration into existing tooling such as podman-py and Podman Desktop, some of which already have code for rendering the compat progress data. We may add a libpod-specific parameter in the future which will stream differnt progress data. Fixes: issues.redhat.com/browse/RUN-1936? Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
This commit is contained in:
@ -28,14 +28,16 @@ func ImagesPull(w http.ResponseWriter, r *http.Request) {
|
||||
runtime := r.Context().Value(api.RuntimeKey).(*libpod.Runtime)
|
||||
decoder := r.Context().Value(api.DecoderKey).(*schema.Decoder)
|
||||
query := struct {
|
||||
Reference string `schema:"reference"`
|
||||
OS string `schema:"OS"`
|
||||
Arch string `schema:"Arch"`
|
||||
Variant string `schema:"Variant"`
|
||||
TLSVerify bool `schema:"tlsVerify"`
|
||||
AllTags bool `schema:"allTags"`
|
||||
CompatMode bool `schema:"compatMode"`
|
||||
PullPolicy string `schema:"policy"`
|
||||
Quiet bool `schema:"quiet"`
|
||||
Reference string `schema:"reference"`
|
||||
TLSVerify bool `schema:"tlsVerify"`
|
||||
// Platform fields below:
|
||||
Arch string `schema:"Arch"`
|
||||
OS string `schema:"OS"`
|
||||
Variant string `schema:"Variant"`
|
||||
}{
|
||||
TLSVerify: true,
|
||||
PullPolicy: "always",
|
||||
@ -46,6 +48,11 @@ func ImagesPull(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if query.Quiet && query.CompatMode {
|
||||
utils.InternalServerError(w, errors.New("'quiet' and 'compatMode' cannot be used simultaneously"))
|
||||
return
|
||||
}
|
||||
|
||||
if len(query.Reference) == 0 {
|
||||
utils.InternalServerError(w, errors.New("reference parameter cannot be empty"))
|
||||
return
|
||||
@ -104,6 +111,11 @@ func ImagesPull(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if query.CompatMode {
|
||||
utils.CompatPull(r.Context(), w, runtime, query.Reference, pullPolicy, pullOptions)
|
||||
return
|
||||
}
|
||||
|
||||
writer := channel.NewWriter(make(chan []byte))
|
||||
defer writer.Close()
|
||||
pullOptions.Writer = writer
|
||||
|
@ -1019,6 +1019,11 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error {
|
||||
// type: boolean
|
||||
// default: false
|
||||
// - in: query
|
||||
// name: compatMode
|
||||
// description: "Return the same JSON payload as the Docker-compat endpoint."
|
||||
// type: boolean
|
||||
// default: false
|
||||
// - in: query
|
||||
// name: Arch
|
||||
// description: Pull image for the specified architecture.
|
||||
// type: string
|
||||
|
@ -49,6 +49,7 @@ t GET images/$iid/json 200 \
|
||||
.RepoTags[0]=$IMAGE
|
||||
|
||||
t POST "images/create?fromImage=alpine" 200 .error~null .status~".*Download complete.*"
|
||||
t POST "libpod/images/pull?reference=alpine&compatMode=true" 200 .error~null .status~".*Download complete.*"
|
||||
|
||||
t POST "images/create?fromImage=alpine&tag=latest" 200
|
||||
|
||||
|
Reference in New Issue
Block a user