Skip to content

make the ephemeral startup configurable for users #37

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 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'

ephemeral-configuration:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would it make more sense to keep this as configuration, similar to what we have in place over in the normal startup action? link: https://github.com/localstack/setup-localstack/blob/main/startup/action.yml

If not, then you'd also have to reflect this argument in the README.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Furthermore this would have to be added in the main action: https://github.com/localstack/setup-localstack/blob/main/action.yml#L138

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

runs:
using: composite
Expand Down Expand Up @@ -70,7 +73,22 @@ runs:
autoLoadPod="${AUTO_LOAD_POD:-${{ inputs.auto-load-pod }}}"
extensionAutoInstall="${EXTENSION_AUTO_INSTALL:-${{ inputs.extension-auto-install }}}"
lifetime="${{ inputs.lifetime }}"
configuration="${{ inputs.ephemeral-configuration }}"
echo "Creating preview environment with configuration: $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
echo "Configuration JSON: $envVarsJson"

envVarsJson=$(echo $envVarsJson | jq --arg autoLoadPod "$autoLoadPod" --arg extensionAutoInstall "$extensionAutoInstall" '. + {AUTO_LOAD_POD: $autoLoadPod, EXTENSION_AUTO_INSTALL: $extensionAutoInstall}')
Comment on lines +76 to +89
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is oddly convoluted, is there a way we could improve readability and maintenance?

echo "*** Configuration ***"
echo $envVarsJson
list_response=$(curl -X GET \
-H "ls-api-key: ${LOCALSTACK_API_KEY:-${{ inputs.localstack-api-key }}}" \
-H "content-type: application/json" \
Expand All @@ -85,7 +103,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
Loading