summaryrefslogtreecommitdiff
path: root/pkg/api/handlers
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-06-25 12:45:53 -0400
committerGitHub <noreply@github.com>2021-06-25 12:45:53 -0400
commit0a0ade3cc00c3779bbf68ddd103d3efd10b5c25b (patch)
tree7a14316df448918e2e54dce77cade7b5cac381b3 /pkg/api/handlers
parentb4767817012a3aedaf05dc7a32bd823fcd3776f4 (diff)
parente7507fe7cf2f35e332f58ae632882f29395e4c59 (diff)
downloadpodman-0a0ade3cc00c3779bbf68ddd103d3efd10b5c25b.tar.gz
podman-0a0ade3cc00c3779bbf68ddd103d3efd10b5c25b.tar.bz2
podman-0a0ade3cc00c3779bbf68ddd103d3efd10b5c25b.zip
Merge pull request #10736 from trusch/feature-use-secret-config
read secret config from config file if no user data.
Diffstat (limited to 'pkg/api/handlers')
-rw-r--r--pkg/api/handlers/libpod/secrets.go16
1 files changed, 14 insertions, 2 deletions
diff --git a/pkg/api/handlers/libpod/secrets.go b/pkg/api/handlers/libpod/secrets.go
index e7f4397ea..7086d9e38 100644
--- a/pkg/api/handlers/libpod/secrets.go
+++ b/pkg/api/handlers/libpod/secrets.go
@@ -1,7 +1,9 @@
package libpod
import (
+ "encoding/json"
"net/http"
+ "reflect"
"github.com/containers/podman/v3/libpod"
"github.com/containers/podman/v3/pkg/api/handlers/utils"
@@ -16,9 +18,17 @@ func CreateSecret(w http.ResponseWriter, r *http.Request) {
runtime = r.Context().Value("runtime").(*libpod.Runtime)
decoder = r.Context().Value("decoder").(*schema.Decoder)
)
+
+ decoder.RegisterConverter(map[string]string{}, func(str string) reflect.Value {
+ res := make(map[string]string)
+ json.Unmarshal([]byte(str), &res)
+ return reflect.ValueOf(res)
+ })
+
query := struct {
- Name string `schema:"name"`
- Driver string `schema:"driver"`
+ Name string `schema:"name"`
+ Driver string `schema:"driver"`
+ DriverOpts map[string]string `schema:"driveropts"`
}{
// override any golang type defaults
}
@@ -28,7 +38,9 @@ func CreateSecret(w http.ResponseWriter, r *http.Request) {
errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String()))
return
}
+
opts.Driver = query.Driver
+ opts.DriverOpts = query.DriverOpts
ic := abi.ContainerEngine{Libpod: runtime}
report, err := ic.SecretCreate(r.Context(), query.Name, r.Body, opts)