Skip to content

Commit 46abfae

Browse files
authored
fix: add dynamic key values to secrets.properties in idx template (#1814)
* 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
1 parent 5790ff2 commit 46abfae

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

open-in-idx-template/idx-template.nix

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,21 @@
1414
chmod -R +w "$WS_NAME"
1515
mkdir -p "$WS_NAME/.idx/"
1616
17-
# Create a secrets.properties file in the repo and replace the MAPS_API_KEY property with said value
17+
# Create a secrets.properties file in the repo
1818
touch $WS_NAME/secrets.properties
19-
echo "MAPS_API_KEY=\"${apikey}\"" > $WS_NAME/secrets.properties
19+
20+
# Create a secrets.properties variable for each key type in the
21+
local.defaults.properties file
22+
23+
while IFS= read -r line || [[ -n "$line" ]]; do
24+
# Check that an "=" exists in the line
25+
if [[ $line == *"="* ]]; then
26+
# Extract the variable name
27+
keyVar=$(echo "$line" | cut -d '=' -f 1)
28+
# Define new variable in secrets file
29+
echo "$keyVar=\"${apikey}\"" >> $WS_NAME/secrets.properties
30+
fi
31+
done < $WS_NAME/local.defaults.properties
2032
2133
# We create a dev.nix that builds the subproject specified at template instantiation
2234
launch_activity=${launchactivity} j2 --format=env ${./devNix.j2} -o $WS_NAME/.idx/dev.nix

0 commit comments

Comments
 (0)