Skip to content

Commit

Permalink
fix: support not remap key for application secret (#16)
Browse files Browse the repository at this point in the history
* fix

* fix

* fix

* fix

* fix

* fix
  • Loading branch information
maximelaboisson authored Aug 9, 2024
1 parent e63f3d6 commit dc46663
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ services:
volumes:
- env:$WORKDIR
- ./test/fixture/volumes/aws-secret:$WORKDIR/aws-secret
- ./test/fixture/volumes/aws-secret-application:$WORKDIR/aws-secret-application
- ./test/fixture/volumes/aws-parameter-store:$WORKDIR/aws-parameter-store
validator:
depends_on: [ env-loader ]
Expand Down
19 changes: 14 additions & 5 deletions parse-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,15 @@ load_dir() {
# Make sure the directory is not empty AND that it's not multi-lined
if [[ "$FILENAME" != "*" && $(($FILE_LINE_COUNT > 1)) == 0 ]]; then
# Replaces underscores with dots
KEY=$(echo "$FILENAME" | tr '_' '.')

# $2, is the numbers of characters to strip in front of the key
KEY="${KEY:$2}"
# $2, is wether ot not to remap `_` to `.` in the key
KEY=$(echo "$FILENAME")
if [ "$2" = true ]; then
KEY=$(echo "$KEY" | tr '_' '.')
fi

# $3, is the numbers of characters to strip in front of the key
KEY="${KEY:$3}"

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

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

log "Loading AWS Secret variables..."
load_dir "$WORKDIR/aws-secret" 0
load_dir "$WORKDIR/aws-secret" true 0
log "Loaded AWS Secret variables"

log "Loading AWS Application Secret variables..."
load_dir "$WORKDIR/aws-secret-application" false 0
log "Loaded AWS Application Secret variables"
1 change: 1 addition & 0 deletions test/expectation/.expected
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ launch-darkly.key=secret_value
openai.key=beepboop
private=password
with.special.chars=@sbSZN%r!r!&9bgE%x&IC%2Bh952U%jD!o&Tww4^ztH#ds@3R44
auth_password=password
1 change: 1 addition & 0 deletions test/fixture/volumes/aws-secret-application/auth_password
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
password

0 comments on commit dc46663

Please sign in to comment.