Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1032 from chardos/resolve-joins
feat: Resolve Fn::Join in environment variables
- Loading branch information
Showing
2 changed files
with
26 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Used to resolve Fn::Join in environment variables | ||
export default function resolveJoins(environment) { | ||
if (!environment) { | ||
return undefined | ||
} | ||
|
||
const newEnv = {} | ||
|
||
Object.keys(environment).forEach((key) => { | ||
const value = environment[key] | ||
const joinArray = value['Fn::Join'] | ||
const isJoin = Boolean(joinArray) | ||
|
||
if (isJoin) { | ||
const separator = joinArray[0] | ||
const joined = joinArray[1].join(separator) | ||
newEnv[key] = joined | ||
} else { | ||
newEnv[key] = value | ||
} | ||
}) | ||
|
||
return newEnv | ||
} |