Skip to content

Commit dc46663

Browse files
fix: support not remap key for application secret (#16)
* fix * fix * fix * fix * fix * fix
1 parent e63f3d6 commit dc46663

File tree

4 files changed

+17
-5
lines changed

4 files changed

+17
-5
lines changed

docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ services:
1111
volumes:
1212
- env:$WORKDIR
1313
- ./test/fixture/volumes/aws-secret:$WORKDIR/aws-secret
14+
- ./test/fixture/volumes/aws-secret-application:$WORKDIR/aws-secret-application
1415
- ./test/fixture/volumes/aws-parameter-store:$WORKDIR/aws-parameter-store
1516
validator:
1617
depends_on: [ env-loader ]

parse-config.sh

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,15 @@ load_dir() {
2020
# Make sure the directory is not empty AND that it's not multi-lined
2121
if [[ "$FILENAME" != "*" && $(($FILE_LINE_COUNT > 1)) == 0 ]]; then
2222
# Replaces underscores with dots
23-
KEY=$(echo "$FILENAME" | tr '_' '.')
2423

25-
# $2, is the numbers of characters to strip in front of the key
26-
KEY="${KEY:$2}"
24+
# $2, is wether ot not to remap `_` to `.` in the key
25+
KEY=$(echo "$FILENAME")
26+
if [ "$2" = true ]; then
27+
KEY=$(echo "$KEY" | tr '_' '.')
28+
fi
29+
30+
# $3, is the numbers of characters to strip in front of the key
31+
KEY="${KEY:$3}"
2732

2833
# Removes the infrastructure.global prefix if it exists
2934
if [[ "$KEY" == "infrastructure.global."* ]]; then
@@ -61,9 +66,13 @@ load_dir() {
6166

6267
# For aws-parameter-store, we strip the first character since it's always a '_'
6368
log "Loading AWS Parameter Store variables..."
64-
load_dir "$WORKDIR/aws-parameter-store" 1
69+
load_dir "$WORKDIR/aws-parameter-store" true 1
6570
log "Loaded AWS Parameter Store variables"
6671

6772
log "Loading AWS Secret variables..."
68-
load_dir "$WORKDIR/aws-secret" 0
73+
load_dir "$WORKDIR/aws-secret" true 0
6974
log "Loaded AWS Secret variables"
75+
76+
log "Loading AWS Application Secret variables..."
77+
load_dir "$WORKDIR/aws-secret-application" false 0
78+
log "Loaded AWS Application Secret variables"

test/expectation/.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ launch-darkly.key=secret_value
55
openai.key=beepboop
66
private=password
77
with.special.chars=@sbSZN%r!r!&9bgE%x&IC%2Bh952U%jD!o&Tww4^ztH#ds@3R44
8+
auth_password=password
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
password

0 commit comments

Comments
 (0)