Skip to content

Commit

Permalink
support xxx/yyy/global
Browse files Browse the repository at this point in the history
  • Loading branch information
dorsradek committed Aug 19, 2024
1 parent 0eb274e commit 7064aee
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 4 deletions.
26 changes: 26 additions & 0 deletions parse-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,34 @@ load_dir() {
KEY=${KEY#"infrastructure.global."}
fi

if [[ "$KEY" =~ infrastructure\.[^.]+\.global\..+ ]]; then
# Remove 'infrastructure.' prefix
TEMP=${KEY#infrastructure.}

# Split off the part after 'global.'
PART_BEFORE_GLOBAL=${TEMP%%.global.*}
PART_AFTER_GLOBAL=${TEMP#*.global.}

# Combine the parts
KEY="${PART_BEFORE_GLOBAL}.${PART_AFTER_GLOBAL}"
fi

# Removes the application.global prefix if it exists
if [[ "$KEY" == "application.global."* ]]; then
KEY=${KEY#"application.global."}
fi

if [[ "$KEY" =~ application\.[^.]+\.global\..+ ]]; then
# Remove 'application.' prefix
TEMP=${KEY#application.}

# Split off the part after 'global.'
PART_BEFORE_GLOBAL=${TEMP%%.global.*}
PART_AFTER_GLOBAL=${TEMP#*.global.}

# Combine the parts
KEY="${PART_BEFORE_GLOBAL}.${PART_AFTER_GLOBAL}"
fi

# Removes the application.$application_name prefix if it exists
if [[ "$KEY" == "application.$APPLICATION_NAME."* ]]; then
Expand Down Expand Up @@ -76,3 +100,5 @@ 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"

sort "$WORKDIR/application.properties" | uniq > "$WORKDIR/temp.properties" && mv "$WORKDIR/temp.properties" "$WORKDIR/application.properties"
6 changes: 3 additions & 3 deletions test/expectation/.expected
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
auth_password=password
kerberos.cache.kerberos-authz.url=kerberos-authz.cache.dev.pleo.io
sqs.sales.endpoint=https://sputnik-buckname.name.com
msk.endpoint=https://msk.com
launch-darkly.key=secret_value
msk.endpoint=https://msk.com
openai.key=beepboop
private=password
sqs.sales.endpoint=https://sputnik-buckname.name.com
with.special.chars=@sbSZN%r!r!&9bgE%x&IC%2Bh952U%jD!o&Tww4^ztH#ds@3R44
auth_password=password
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
kerberos-authz.cache.dev.pleo.io
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
secret_value
2 changes: 1 addition & 1 deletion test/validate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ else
echo $(diff $result $expected)

exit 1
fi
fi

0 comments on commit 7064aee

Please sign in to comment.