Skip to content

Commit 18b46b6

Browse files
committed
make the ephemeral startup configurable for users
1 parent 5b17176 commit 18b46b6

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

ephemeral/startup/action.yml

+18-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ inputs:
2323
description: 'The lifetime of the ephemeral instance, how long the instance should be available for'
2424
required: false
2525
default: '30'
26-
26+
configuration:
27+
description: 'Configuration for the LocalStack environment to be created'
28+
required: false
29+
default: ''
2730

2831
runs:
2932
using: composite
@@ -70,6 +73,19 @@ runs:
7073
autoLoadPod="${AUTO_LOAD_POD:-${{ inputs.auto-load-pod }}}"
7174
extensionAutoInstall="${EXTENSION_AUTO_INSTALL:-${{ inputs.extension-auto-install }}}"
7275
lifetime="${{ inputs.lifetime }}"
76+
configuration='${{ inputs.configuration }}'
77+
78+
# Convert configuration to JSON format
79+
IFS=',' read -r -a configArray <<< "$configuration"
80+
envVarsJson=$(jq -n '{}')
81+
for config in "${configArray[@]}"; do
82+
IFS='=' read -r -a kv <<< "$config"
83+
key=${kv[0]// /}
84+
value=${kv[1]// /}
85+
envVarsJson=$(echo $envVarsJson | jq --arg key "$key" --arg value "$value" '. + {($key): $value}')
86+
done
87+
88+
envVarsJson=$(echo $envVarsJson | jq --arg autoLoadPod "$autoLoadPod" --arg extensionAutoInstall "$extensionAutoInstall" '. + {AUTO_LOAD_POD: $autoLoadPod, EXTENSION_AUTO_INSTALL: $extensionAutoInstall}')
7389
7490
list_response=$(curl -X GET \
7591
-H "ls-api-key: ${LOCALSTACK_API_KEY:-${{ inputs.localstack-api-key }}}" \
@@ -85,7 +101,7 @@ runs:
85101
https://api.localstack.cloud/v1/compute/instances/$previewName)
86102
fi
87103
88-
response=$(curl -X POST -d "{\"instance_name\": \"${previewName}\", \"lifetime\": ${lifetime} ,\"env_vars\": {\"AUTO_LOAD_POD\": \"${autoLoadPod}\", \"EXTENSION_AUTO_INSTALL\": \"${extensionAutoInstall}\"}}"\
104+
response=$(curl -X POST -d "{\"instance_name\": \"${previewName}\", \"lifetime\": ${lifetime}, \"env_vars\": ${envVarsJson}}"\
89105
-H "ls-api-key: ${LOCALSTACK_API_KEY:-${{ inputs.localstack-api-key }}}" \
90106
-H "content-type: application/json" \
91107
https://api.localstack.cloud/v1/compute/instances)

0 commit comments

Comments
 (0)