From 51a5cdc6366905cde09e8efb7afa06f51ef9c67b Mon Sep 17 00:00:00 2001 From: umohnani8 Date: Thu, 26 Apr 2018 16:41:06 -0400 Subject: 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 Closes: #685 Approved by: mheon --- pkg/secrets/secrets.go | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'pkg') 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) -- cgit v1.2.3-54-g00ecf