diff options
author | baude <bbaude@redhat.com> | 2021-03-01 08:42:48 -0600 |
---|---|---|
committer | baude <bbaude@redhat.com> | 2021-03-02 10:56:28 -0600 |
commit | 2c8c5393a492929b75dd459889a1c1ef28e2b393 (patch) | |
tree | f166e5fdf24dc5b010c35f77130bf7337646ff52 /pkg/api | |
parent | 7497dcba6cd240908a9b0948eb561ad9c264fc8f (diff) | |
download | podman-2c8c5393a492929b75dd459889a1c1ef28e2b393.tar.gz podman-2c8c5393a492929b75dd459889a1c1ef28e2b393.tar.bz2 podman-2c8c5393a492929b75dd459889a1c1ef28e2b393.zip |
Support label type dict on compat build
The compatibility endpoint for build labels should be of type dict (not
list). For backwards compatibility, we support both.
Fixes: #9517
Signed-off-by: baude <bbaude@redhat.com>
Diffstat (limited to 'pkg/api')
-rw-r--r-- | pkg/api/handlers/compat/images_build.go | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/pkg/api/handlers/compat/images_build.go b/pkg/api/handlers/compat/images_build.go index d79b100e8..2b84c9a25 100644 --- a/pkg/api/handlers/compat/images_build.go +++ b/pkg/api/handlers/compat/images_build.go @@ -221,9 +221,17 @@ func BuildImage(w http.ResponseWriter, r *http.Request) { // convert label formats var labels = []string{} if _, found := r.URL.Query()["labels"]; found { - if err := json.Unmarshal([]byte(query.Labels), &labels); err != nil { - utils.BadRequest(w, "labels", query.Labels, err) - return + makeLabels := make(map[string]string) + err := json.Unmarshal([]byte(query.Labels), &makeLabels) + if err == nil { + for k, v := range makeLabels { + labels = append(labels, k+"="+v) + } + } else { + if err := json.Unmarshal([]byte(query.Labels), &labels); err != nil { + utils.BadRequest(w, "labels", query.Labels, err) + return + } } } jobs := 1 |