Skip to content

Commit

Permalink
make the ephemeral startup configurable for users
Browse files Browse the repository at this point in the history
  • Loading branch information
HarshCasper committed Aug 9, 2024
1 parent 5b17176 commit 18b46b6
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions ephemeral/startup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ inputs:
description: 'The lifetime of the ephemeral instance, how long the instance should be available for'
required: false
default: '30'

configuration:
description: 'Configuration for the LocalStack environment to be created'
required: false
default: ''

runs:
using: composite
Expand Down Expand Up @@ -70,6 +73,19 @@ runs:
autoLoadPod="${AUTO_LOAD_POD:-${{ inputs.auto-load-pod }}}"
extensionAutoInstall="${EXTENSION_AUTO_INSTALL:-${{ inputs.extension-auto-install }}}"
lifetime="${{ inputs.lifetime }}"
configuration='${{ inputs.configuration }}'
# Convert configuration to JSON format
IFS=',' read -r -a configArray <<< "$configuration"
envVarsJson=$(jq -n '{}')
for config in "${configArray[@]}"; do
IFS='=' read -r -a kv <<< "$config"
key=${kv[0]// /}
value=${kv[1]// /}
envVarsJson=$(echo $envVarsJson | jq --arg key "$key" --arg value "$value" '. + {($key): $value}')
done
envVarsJson=$(echo $envVarsJson | jq --arg autoLoadPod "$autoLoadPod" --arg extensionAutoInstall "$extensionAutoInstall" '. + {AUTO_LOAD_POD: $autoLoadPod, EXTENSION_AUTO_INSTALL: $extensionAutoInstall}')
list_response=$(curl -X GET \
-H "ls-api-key: ${LOCALSTACK_API_KEY:-${{ inputs.localstack-api-key }}}" \
Expand All @@ -85,7 +101,7 @@ runs:
https://api.localstack.cloud/v1/compute/instances/$previewName)
fi
response=$(curl -X POST -d "{\"instance_name\": \"${previewName}\", \"lifetime\": ${lifetime} ,\"env_vars\": {\"AUTO_LOAD_POD\": \"${autoLoadPod}\", \"EXTENSION_AUTO_INSTALL\": \"${extensionAutoInstall}\"}}"\
response=$(curl -X POST -d "{\"instance_name\": \"${previewName}\", \"lifetime\": ${lifetime}, \"env_vars\": ${envVarsJson}}"\
-H "ls-api-key: ${LOCALSTACK_API_KEY:-${{ inputs.localstack-api-key }}}" \
-H "content-type: application/json" \
https://api.localstack.cloud/v1/compute/instances)
Expand Down

0 comments on commit 18b46b6

Please sign in to comment.