Skip to content

Commit

Permalink
fix: add dynamic key values to secrets.properties in idx template (#1814
Browse files Browse the repository at this point in the history
)

* Add dynamic key values to secrets.properties in idx template

Update idx template to read local.defaults.properties and
generate key entries in secrets.properties file using the
user's provided API key.

* Fix incorrect variable for key

Update key to be keyVar when writing to secrets.properties
  • Loading branch information
cemanzano authored Sep 20, 2024
1 parent 5790ff2 commit 46abfae
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions open-in-idx-template/idx-template.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,21 @@
chmod -R +w "$WS_NAME"
mkdir -p "$WS_NAME/.idx/"
# Create a secrets.properties file in the repo and replace the MAPS_API_KEY property with said value
# Create a secrets.properties file in the repo
touch $WS_NAME/secrets.properties
echo "MAPS_API_KEY=\"${apikey}\"" > $WS_NAME/secrets.properties
# Create a secrets.properties variable for each key type in the
local.defaults.properties file
while IFS= read -r line || [[ -n "$line" ]]; do
# Check that an "=" exists in the line
if [[ $line == *"="* ]]; then
# Extract the variable name
keyVar=$(echo "$line" | cut -d '=' -f 1)
# Define new variable in secrets file
echo "$keyVar=\"${apikey}\"" >> $WS_NAME/secrets.properties
fi
done < $WS_NAME/local.defaults.properties
# We create a dev.nix that builds the subproject specified at template instantiation
launch_activity=${launchactivity} j2 --format=env ${./devNix.j2} -o $WS_NAME/.idx/dev.nix
Expand Down

0 comments on commit 46abfae

Please sign in to comment.