summaryrefslogtreecommitdiff
path: root/pkg/domain/infra
diff options
context:
space:
mode:
authorTino Rusch <tino.rusch@gmail.com>2021-06-20 16:11:54 +0200
committerTino Rusch <tino.rusch@gmail.com>2021-06-24 12:31:14 +0200
commitb56b4b53744c59cad942278ff34a0b0616a7aa60 (patch)
tree77bb7ead8c1f2ccedc31eaa5dc1cc06483555947 /pkg/domain/infra
parentda33fc45b6628c1ac1a16e49790be2b4fbf502a5 (diff)
downloadpodman-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/domain/infra')
-rw-r--r--pkg/domain/infra/abi/secrets.go26
-rw-r--r--pkg/domain/infra/tunnel/secrets.go10
2 files changed, 29 insertions, 7 deletions
diff --git a/pkg/domain/infra/abi/secrets.go b/pkg/domain/infra/abi/secrets.go
index 1e1cbc70f..fa28a9b51 100644
--- a/pkg/domain/infra/abi/secrets.go
+++ b/pkg/domain/infra/abi/secrets.go
@@ -17,15 +17,30 @@ func (ic *ContainerEngine) SecretCreate(ctx context.Context, name string, reader
if err != nil {
return nil, err
}
- driverOptions := make(map[string]string)
+ // set defaults from config for the case they are not set by an upper layer
+ // (-> i.e. tests that talk directly to the api)
+ cfg, err := ic.Libpod.GetConfig()
+ if err != nil {
+ return nil, err
+ }
if options.Driver == "" {
- options.Driver = "file"
+ options.Driver = cfg.Secrets.Driver
+ }
+ if len(options.Opts) == 0 {
+ options.Opts = cfg.Secrets.Opts
+ }
+ if options.Opts == nil {
+ options.Opts = make(map[string]string)
}
+
if options.Driver == "file" {
- driverOptions["path"] = filepath.Join(secretsPath, "filedriver")
+ if _, ok := options.Opts["path"]; !ok {
+ options.Opts["path"] = filepath.Join(secretsPath, "filedriver")
+ }
}
- secretID, err := manager.Store(name, data, options.Driver, driverOptions)
+
+ secretID, err := manager.Store(name, data, options.Driver, options.Opts)
if err != nil {
return nil, err
}
@@ -58,7 +73,8 @@ func (ic *ContainerEngine) SecretInspect(ctx context.Context, nameOrIDs []string
Spec: entities.SecretSpec{
Name: secret.Name,
Driver: entities.SecretDriverSpec{
- Name: secret.Driver,
+ Name: secret.Driver,
+ Options: secret.DriverOptions,
},
},
}
diff --git a/pkg/domain/infra/tunnel/secrets.go b/pkg/domain/infra/tunnel/secrets.go
index 1153f490e..8cdc220a4 100644
--- a/pkg/domain/infra/tunnel/secrets.go
+++ b/pkg/domain/infra/tunnel/secrets.go
@@ -11,8 +11,14 @@ import (
)
func (ic *ContainerEngine) SecretCreate(ctx context.Context, name string, reader io.Reader, options entities.SecretCreateOptions) (*entities.SecretCreateReport, error) {
- opts := new(secrets.CreateOptions).WithDriver(options.Driver).WithName(name)
- created, _ := secrets.Create(ic.ClientCtx, reader, opts)
+ opts := new(secrets.CreateOptions).
+ WithDriver(options.Driver).
+ WithDriverOpts(options.Opts).
+ WithName(name)
+ created, err := secrets.Create(ic.ClientCtx, reader, opts)
+ if err != nil {
+ return nil, err
+ }
return created, nil
}