summaryrefslogtreecommitdiff
path: root/libpod/options.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-05-07 05:34:26 -0400
committerGitHub <noreply@github.com>2021-05-07 05:34:26 -0400
commit141ba94f9735d88a494f252ad7aa78fd4b86d8ea (patch)
tree6381cf512d4e9d99747e90004d4be024036687d8 /libpod/options.go
parent41ac68d197b53f3c151b81e2eddbc00bcf1a117f (diff)
parent2634cb234f1500b76a2fd89351b9ad8a737a24ea (diff)
downloadpodman-141ba94f9735d88a494f252ad7aa78fd4b86d8ea.tar.gz
podman-141ba94f9735d88a494f252ad7aa78fd4b86d8ea.tar.bz2
podman-141ba94f9735d88a494f252ad7aa78fd4b86d8ea.zip
Merge pull request #10221 from ashley-cui/envsec
Add support for environment variable secrets
Diffstat (limited to 'libpod/options.go')
-rw-r--r--libpod/options.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/libpod/options.go b/libpod/options.go
index 391cf0147..be26ced99 100644
--- a/libpod/options.go
+++ b/libpod/options.go
@@ -1716,6 +1716,28 @@ func WithSecrets(secretNames []string) CtrCreateOption {
}
}
+// WithSecrets adds environment variable secrets to the container
+func WithEnvSecrets(envSecrets map[string]string) CtrCreateOption {
+ return func(ctr *Container) error {
+ ctr.config.EnvSecrets = make(map[string]*secrets.Secret)
+ if ctr.valid {
+ return define.ErrCtrFinalized
+ }
+ manager, err := secrets.NewManager(ctr.runtime.GetSecretsStorageDir())
+ if err != nil {
+ return err
+ }
+ for target, src := range envSecrets {
+ secr, err := manager.Lookup(src)
+ if err != nil {
+ return err
+ }
+ ctr.config.EnvSecrets[target] = secr
+ }
+ return nil
+ }
+}
+
// WithPidFile adds pidFile to the container
func WithPidFile(pidFile string) CtrCreateOption {
return func(ctr *Container) error {