Skip to content
This repository has been archived by the owner on Feb 16, 2023. It is now read-only.

Commit

Permalink
Merge pull request #352 from secrethub/fix/valid-envar-conversion
Browse files Browse the repository at this point in the history
Add missing replacements for valid envar generation
  • Loading branch information
SimonBarendse authored Oct 1, 2020
2 parents b7b75e5 + 3480d38 commit bdcabec
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion internals/secrethub/env_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit bdcabec

Please sign in to comment.