summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorumohnani8 <umohnani@redhat.com>2018-04-26 16:41:06 -0400
committerAtomic Bot <atomic-devel@projectatomic.io>2018-04-27 14:07:54 +0000
commit51a5cdc6366905cde09e8efb7afa06f51ef9c67b (patch)
treea9b486e3dbc5229d35f88ffe58a0559bf3b3b190
parent39a7a773a653176e294382bc6301275fd57aff6b (diff)
downloadpodman-51a5cdc6366905cde09e8efb7afa06f51ef9c67b.tar.gz
podman-51a5cdc6366905cde09e8efb7afa06f51ef9c67b.tar.bz2
podman-51a5cdc6366905cde09e8efb7afa06f51ef9c67b.zip
Modify secrets pkg
Made a mistake in my earlier patch. I though that if you add an empty string to an array, the length of the array would still be 0... Realised this when vendoring the secrets pkg into cri-o. Signed-off-by: umohnani8 <umohnani@redhat.com> Closes: #685 Approved by: mheon
-rw-r--r--libpod/options.go5
-rw-r--r--libpod/runtime.go2
-rw-r--r--pkg/secrets/secrets.go15
3 files changed, 15 insertions, 7 deletions
diff --git a/libpod/options.go b/libpod/options.go
index 202cfe9a3..981ca9a9d 100644
--- a/libpod/options.go
+++ b/libpod/options.go
@@ -194,7 +194,10 @@ func WithDefaultMountsFile(mountsFile string) RuntimeOption {
return ErrRuntimeFinalized
}
- rt.config.DefaultMountsFile = []string{mountsFile}
+ if mountsFile == "" {
+ return ErrInvalidArg
+ }
+ rt.config.DefaultMountsFile = mountsFile
return nil
}
}
diff --git a/libpod/runtime.go b/libpod/runtime.go
index f46fc8851..9de70da1b 100644
--- a/libpod/runtime.go
+++ b/libpod/runtime.go
@@ -132,7 +132,7 @@ type RuntimeConfig struct {
// HooksDir Path to the directory containing hooks configuration files
HooksDir string `toml:"hooks_dir"`
// DefaultMountsFile is the path to the default mounts file for testing purposes only
- DefaultMountsFile []string `toml:"-"`
+ DefaultMountsFile string `toml:"-"`
}
var (
diff --git a/pkg/secrets/secrets.go b/pkg/secrets/secrets.go
index 54d1ae5ad..04890c06a 100644
--- a/pkg/secrets/secrets.go
+++ b/pkg/secrets/secrets.go
@@ -127,15 +127,20 @@ func getMountsMap(path string) (string, string, error) {
}
// SecretMounts copies, adds, and mounts the secrets to the container root filesystem
-func SecretMounts(mountLabel, containerWorkingDir string, mountFile []string) []rspec.Mount {
- var secretMounts []rspec.Mount
+func SecretMounts(mountLabel, containerWorkingDir string, mountFile string) []rspec.Mount {
+ var (
+ secretMounts []rspec.Mount
+ mountFiles []string
+ )
// Add secrets from paths given in the mounts.conf files
// mountFile will have a value if the hidden --default-mounts-file flag is set
// Note for testing purposes only
- if len(mountFile) == 0 {
- mountFile = append(mountFile, []string{OverrideMountsFile, DefaultMountsFile}...)
+ if mountFile == "" {
+ mountFiles = append(mountFiles, []string{OverrideMountsFile, DefaultMountsFile}...)
+ } else {
+ mountFiles = append(mountFiles, mountFile)
}
- for _, file := range mountFile {
+ for _, file := range mountFiles {
mounts, err := addSecretsFromMountsFile(file, mountLabel, containerWorkingDir)
if err != nil {
logrus.Warnf("error mounting secrets, skipping: %v", err)