From 198fd0df450d9803c564a633f23d24e2d3993afe Mon Sep 17 00:00:00 2001 From: Cean Manzano Date: Fri, 20 Sep 2024 11:55:33 -0700 Subject: [PATCH 1/2] 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. --- open-in-idx-template/idx-template.nix | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/open-in-idx-template/idx-template.nix b/open-in-idx-template/idx-template.nix index ed230f863..74efce177 100644 --- a/open-in-idx-template/idx-template.nix +++ b/open-in-idx-template/idx-template.nix @@ -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 "$key=\"${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 From a1d2f0bd05f72d848fd160e8f16704bdc35e1f77 Mon Sep 17 00:00:00 2001 From: Cean Manzano Date: Fri, 20 Sep 2024 12:02:49 -0700 Subject: [PATCH 2/2] Fix incorrect variable for key Update key to be keyVar when writing to secrets.properties --- open-in-idx-template/idx-template.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/open-in-idx-template/idx-template.nix b/open-in-idx-template/idx-template.nix index 74efce177..c9e17d1f4 100644 --- a/open-in-idx-template/idx-template.nix +++ b/open-in-idx-template/idx-template.nix @@ -26,7 +26,7 @@ # Extract the variable name keyVar=$(echo "$line" | cut -d '=' -f 1) # Define new variable in secrets file - echo "$key=\"${apikey}\"" >> $WS_NAME/secrets.properties + echo "$keyVar=\"${apikey}\"" >> $WS_NAME/secrets.properties fi done < $WS_NAME/local.defaults.properties