Skip to content

Commit

Permalink
fix: repair errors in startup shell script (#1087)
Browse files Browse the repository at this point in the history
## Description

The startup shell script of the Agent instance was broken due to missing
tests (to be addressed in #1088 ). Fixed the script and validated it
with shellchecker.

- `if` needs `then`
- no spaces in `=` assignments
- use `$` to get the value of a variable

## Verification

- module deployed in the test environment. Runners were spawn, jobs
processed.
- Cloudwatch logs checked for errors, none found
  • Loading branch information
kayman-mk committed Feb 15, 2024
1 parent df39014 commit 9b7c465
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions template/gitlab-runner.tftpl
Expand Up @@ -49,7 +49,7 @@ then
# fetch gitlab token from SSM
gitlab_token=$(aws ssm get-parameter --name "${secure_parameter_store_gitlab_token_name}" --with-decryption --region "${secure_parameter_store_region}" | jq -r ".Parameter | .Value")

response = $(curl ${curl_cacert} --request POST -L "${runners_gitlab_url}/api/v4/user/runners" \
response=$(curl ${curl_cacert} --request POST -L "${runners_gitlab_url}/api/v4/user/runners" \
--header "private-token: $gitlab_token" \
--form "tag_list=${gitlab_runner_tag_list}" \
--form "description=${gitlab_runner_description}" \
Expand All @@ -60,10 +60,12 @@ then
$runner_type_param \
--form "access_level=${gitlab_runner_access_level}")

token = $(echo response | jq -r '.token')
token=$(echo $response | jq -r '.token')
if [[ "$token" == null ]]
message = $(echo response | jq -r '.message // .error_description')
then
message=$(echo $response | jq -r '.message // .error_description')
if [[ "$message" != null ]]
then
echo "ERROR: Couldn't register the Runner. GitLab API call returned $message".
exit 1
fi
Expand Down

0 comments on commit 9b7c465

Please sign in to comment.