From 7dbb8f66be2cd01cbf340dacd20f3a3f1e1af975 Mon Sep 17 00:00:00 2001 From: Eduard Filip Date: Thu, 1 Oct 2020 14:16:24 +0200 Subject: [PATCH 1/2] Add missing replacements for valid envar generation Two characters that are in secrethub paths are not valid in envar naming: '.' and '-'. Now they will be replaced with '_'. --- internals/secrethub/env_source.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/internals/secrethub/env_source.go b/internals/secrethub/env_source.go index 611c6dc8..90fee3bc 100644 --- a/internals/secrethub/env_source.go +++ b/internals/secrethub/env_source.go @@ -247,6 +247,8 @@ func (s *secretsDirEnv) envVarName(path string) string { envVarName := strings.TrimPrefix(path, s.dirPath) envVarName = strings.TrimPrefix(envVarName, "/") envVarName = strings.ReplaceAll(envVarName, "/", "_") + envVarName = strings.ReplaceAll(envVarName, "-", "_") + envVarName = strings.ReplaceAll(envVarName, ".", "_") envVarName = strings.ToUpper(envVarName) return envVarName } From 3480d386527b2d1af9b6ef12bf2eac2b3830721c Mon Sep 17 00:00:00 2001 From: Eduard Filip Date: Thu, 1 Oct 2020 14:46:27 +0200 Subject: [PATCH 2/2] Update --secrets-dir flag helper text --- internals/secrethub/env_source.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internals/secrethub/env_source.go b/internals/secrethub/env_source.go index 90fee3bc..4f0e74f6 100644 --- a/internals/secrethub/env_source.go +++ b/internals/secrethub/env_source.go @@ -66,7 +66,7 @@ func (env *environment) register(clause *cli.CommandClause) { clause.Flag("var", "Define the value for a template variable with `VAR=VALUE`, e.g. --var env=prod").Short('v').StringMapVar(&env.templateVars) clause.Flag("template-version", "The template syntax version to be used. The options are v1, v2, latest or auto to automatically detect the version.").Default("auto").StringVar(&env.templateVersion) clause.Flag("no-prompt", "Do not prompt when a template variable is missing and return an error instead.").BoolVar(&env.dontPromptMissingTemplateVar) - clause.Flag("secrets-dir", "Recursively include all secrets from a directory. Environment variable names are derived from the path of the secret: `/` are replaced with `_` and the name is uppercased.").StringVar(&env.secretsDir) + clause.Flag("secrets-dir", "Recursively load all secrets from a directory into environment variables. Names of the environment variables are derived from the path of the secret: all `/`, '-' and '.' are replaced with `_` and the name is uppercased.").StringVar(&env.secretsDir) clause.Flag("env", "The name of the environment prepared by the set command (default is `default`)").Default("default").Hidden().StringVar(&env.secretsEnvDir) }