Skip to content

Commit

Permalink
feature: support for Env Vars with parse-json
Browse files Browse the repository at this point in the history
  • Loading branch information
John Torakis committed Sep 19, 2022
1 parent 6856d8d commit 5fc16d4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/awsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ const fetchAndInject = (secretsManagerClient: SecretsManager,
}
getSecretValueMap(secretsManagerClient, secretName, shouldParseJSON)
.then(map => {
injectSecretValueMapToEnvironment(map, secretEnvVarName)
injectSecretValueMapToEnvironment(map, secretName, secretEnvVarName)
})
.catch(err => {
core.setFailed(`Failed to fetch '${secretName}'. Error: ${err}.`)
Expand Down
6 changes: 3 additions & 3 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export const getPOSIXString = (data: string): string => {
}

export const injectSecretValueMapToEnvironment = (secretValueMap: Record<string, any>,
secretEnvVarName: string): void => {
secretPath: string, secretEnvVarName: string): void => {
const disableWarnings = core.getBooleanInput(Inputs.DISABLE_WARNINGS)

for (const secretName in secretValueMap) {
Expand All @@ -76,7 +76,7 @@ export const injectSecretValueMapToEnvironment = (secretValueMap: Record<string,
else {
// If an Environment Variable is given by the user with the '|' syntax
// use it directly
secretNamePOSIX = secretEnvVarName
secretNamePOSIX = getPOSIXString(secretName.replace(secretPath, secretEnvVarName))
}
if (secretEnvVarName === undefined && secretName !== secretNamePOSIX && !disableWarnings) {
core.warning('One of the secrets has a name that is not POSIX compliant and hence cannot directly \
Expand All @@ -87,7 +87,7 @@ see the transformed environment variable name.\nPOSIX compliance: environment va
upper case letters, digits and underscores. It cannot begin with a digit.')
core.debug(`Secret name '${secretName}' is not POSIX compliant. It will be transformed to '${secretNamePOSIX}'.`)
}
core.debug(`Injecting environment variable '${secretNamePOSIX}'.`)
core.debug(`Injecting secret: '${secretName}' in Environment Variable: '${secretNamePOSIX}'.`)
core.exportVariable(secretNamePOSIX, secretValue)
}
}

0 comments on commit 5fc16d4

Please sign in to comment.