From 73f7d61743304c757242da844ec79d2c0b91ae57 Mon Sep 17 00:00:00 2001 From: Oliver Nocon <33484802+OliverNocon@users.noreply.github.com> Date: Thu, 4 Aug 2022 09:20:59 +0200 Subject: [PATCH] fix: remove side-effects of #3875 (#3928) with #3875 temp directory was created in current workspace. This had negative side-effects: For example npm build packaged and published temporary files Co-authored-by: Anil Keshav --- pkg/config/vault.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pkg/config/vault.go b/pkg/config/vault.go index 88d595dc4..ca5992578 100644 --- a/pkg/config/vault.go +++ b/pkg/config/vault.go @@ -9,7 +9,7 @@ import ( "github.com/SAP/jenkins-library/pkg/config/interpolation" "github.com/SAP/jenkins-library/pkg/log" - CredentialUtils "github.com/SAP/jenkins-library/pkg/piperutils" + "github.com/SAP/jenkins-library/pkg/piperutils" "github.com/SAP/jenkins-library/pkg/vault" "github.com/hashicorp/vault/api" ) @@ -285,7 +285,7 @@ func populateCredentialsAsEnvs(config *StepConfig, secret map[string]string, key os.Setenv(envVariable, secretValue) envVariable = vaultCredentialEnvPrefix + convertEnvVar(secretKey) + "_BASE64" log.Entry().Debugf("Exposing general purpose base64 encoded credential '%v' as '%v'", key, envVariable) - os.Setenv(envVariable, CredentialUtils.EncodeString(secretValue)) + os.Setenv(envVariable, piperutils.EncodeString(secretValue)) matched = true } } @@ -303,7 +303,7 @@ func populateCredentialsAsEnvs(config *StepConfig, secret map[string]string, key os.Setenv(envVariable, secretValue) envVariable = vaultCredentialEnvPrefixDefault + convertEnvVar(secretKey) + "_BASE64" log.Entry().Debugf("Exposing general purpose base64 encoded credential '%v' as '%v'", key, envVariable) - os.Setenv(envVariable, CredentialUtils.EncodeString(secretValue)) + os.Setenv(envVariable, piperutils.EncodeString(secretValue)) matched = true } } @@ -369,7 +369,8 @@ func RemoveVaultSecretFiles() { func createTemporarySecretFile(namePattern string, content string) (string, error) { if VaultSecretFileDirectory == "" { var err error - VaultSecretFileDirectory, err = ioutil.TempDir(".", "vault") + fileUtils := &piperutils.Files{} + VaultSecretFileDirectory, err = fileUtils.TempDir("", "vault") if err != nil { return "", err }