diff options
Diffstat (limited to 'pkg/domain/infra')
-rw-r--r-- | pkg/domain/infra/abi/secrets.go | 26 | ||||
-rw-r--r-- | pkg/domain/infra/tunnel/secrets.go | 10 |
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 } |