diff options
author | Tino Rusch <tino.rusch@gmail.com> | 2021-06-20 16:11:54 +0200 |
---|---|---|
committer | Tino Rusch <tino.rusch@gmail.com> | 2021-06-24 12:31:14 +0200 |
commit | b56b4b53744c59cad942278ff34a0b0616a7aa60 (patch) | |
tree | 77bb7ead8c1f2ccedc31eaa5dc1cc06483555947 /pkg/api/handlers/libpod | |
parent | da33fc45b6628c1ac1a16e49790be2b4fbf502a5 (diff) | |
download | podman-b56b4b53744c59cad942278ff34a0b0616a7aa60.tar.gz podman-b56b4b53744c59cad942278ff34a0b0616a7aa60.tar.bz2 podman-b56b4b53744c59cad942278ff34a0b0616a7aa60.zip |
read secret config from config file if no user data.
feat: read secret config from config file if the user hasn't entered
explicit config values
feat: allow to specify `--driver-opts opt1=val1,opt2=val2` in the secret
create command to allow overriding the default values
fix: show driver options in `podman secret inspect`
Signed-off-by: Tino Rusch <tino.rusch@gmail.com>
Diffstat (limited to 'pkg/api/handlers/libpod')
-rw-r--r-- | pkg/api/handlers/libpod/secrets.go | 16 |
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..867a0b957 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.Opts = query.DriverOpts ic := abi.ContainerEngine{Libpod: runtime} report, err := ic.SecretCreate(r.Context(), query.Name, r.Body, opts) |