diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2021-06-25 12:45:53 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-25 12:45:53 -0400 |
commit | 0a0ade3cc00c3779bbf68ddd103d3efd10b5c25b (patch) | |
tree | 7a14316df448918e2e54dce77cade7b5cac381b3 /pkg/domain | |
parent | b4767817012a3aedaf05dc7a32bd823fcd3776f4 (diff) | |
parent | e7507fe7cf2f35e332f58ae632882f29395e4c59 (diff) | |
download | podman-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/domain')
-rw-r--r-- | pkg/domain/entities/secrets.go | 3 | ||||
-rw-r--r-- | pkg/domain/infra/abi/secrets.go | 26 | ||||
-rw-r--r-- | pkg/domain/infra/tunnel/secrets.go | 10 |
3 files changed, 31 insertions, 8 deletions
diff --git a/pkg/domain/entities/secrets.go b/pkg/domain/entities/secrets.go index 8ede981da..56a1465b7 100644 --- a/pkg/domain/entities/secrets.go +++ b/pkg/domain/entities/secrets.go @@ -11,7 +11,8 @@ type SecretCreateReport struct { } type SecretCreateOptions struct { - Driver string + Driver string + DriverOpts map[string]string } type SecretListRequest struct { diff --git a/pkg/domain/infra/abi/secrets.go b/pkg/domain/infra/abi/secrets.go index 1e1cbc70f..0bdb4ce60 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.DriverOpts) == 0 { + options.DriverOpts = cfg.Secrets.Opts + } + if options.DriverOpts == nil { + options.DriverOpts = make(map[string]string) } + if options.Driver == "file" { - driverOptions["path"] = filepath.Join(secretsPath, "filedriver") + if _, ok := options.DriverOpts["path"]; !ok { + options.DriverOpts["path"] = filepath.Join(secretsPath, "filedriver") + } } - secretID, err := manager.Store(name, data, options.Driver, driverOptions) + + secretID, err := manager.Store(name, data, options.Driver, options.DriverOpts) 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..ecbb80931 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.DriverOpts). + WithName(name) + created, err := secrets.Create(ic.ClientCtx, reader, opts) + if err != nil { + return nil, err + } return created, nil } |