summaryrefslogtreecommitdiff
path: root/pkg/api
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-10-29 09:36:28 +0000
committerGitHub <noreply@github.com>2021-10-29 09:36:28 +0000
commit197152b02ba2b3f8e56dc08ff3b30a4175b4b158 (patch)
tree961656f4bb1b252de10f319b4defee1ec30864cd /pkg/api
parentf7ca0457378f8e640d63995965ef1b1e2f0d8eac (diff)
parent98506c961b9e0d155c1e0d124bb95d72cbb1d8c3 (diff)
downloadpodman-197152b02ba2b3f8e56dc08ff3b30a4175b4b158.tar.gz
podman-197152b02ba2b3f8e56dc08ff3b30a4175b4b158.tar.bz2
podman-197152b02ba2b3f8e56dc08ff3b30a4175b4b158.zip
Merge pull request #12133 from jwhonce/issues/12102
Allow label and labels when creating volumes
Diffstat (limited to 'pkg/api')
-rw-r--r--pkg/api/handlers/libpod/volumes.go17
1 files changed, 14 insertions, 3 deletions
diff --git a/pkg/api/handlers/libpod/volumes.go b/pkg/api/handlers/libpod/volumes.go
index 3ba39b860..ffdb30551 100644
--- a/pkg/api/handlers/libpod/volumes.go
+++ b/pkg/api/handlers/libpod/volumes.go
@@ -29,12 +29,13 @@ func CreateVolume(w http.ResponseWriter, r *http.Request) {
}{
// override any golang type defaults
}
- input := entities.VolumeCreateOptions{}
if err := decoder.Decode(&query, r.URL.Query()); err != nil {
utils.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError,
errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String()))
return
}
+
+ input := entities.VolumeCreateOptions{}
// decode params from body
if err := json.NewDecoder(r.Body).Decode(&input); err != nil {
utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "Decode()"))
@@ -47,9 +48,19 @@ func CreateVolume(w http.ResponseWriter, r *http.Request) {
if len(input.Driver) > 0 {
volumeOptions = append(volumeOptions, libpod.WithVolumeDriver(input.Driver))
}
- if len(input.Label) > 0 {
- volumeOptions = append(volumeOptions, libpod.WithVolumeLabels(input.Label))
+
+ // Label provided for compatibility.
+ labels := make(map[string]string, len(input.Label)+len(input.Labels))
+ for k, v := range input.Label {
+ labels[k] = v
}
+ for k, v := range input.Labels {
+ labels[k] = v
+ }
+ if len(labels) > 0 {
+ volumeOptions = append(volumeOptions, libpod.WithVolumeLabels(labels))
+ }
+
if len(input.Options) > 0 {
parsedOptions, err := parse.VolumeOptions(input.Options)
if err != nil {