Skip to content

Commit e5a7986

Browse files
authored
Merge pull request #29 from StackGuardian/fix/private-runner-instance-attributes
[SG-2828] Fix/private runner instance attributes
2 parents 243b37d + f645abf commit e5a7986

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

main.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -840,10 +840,17 @@ configure_local_data() { #{{{
840840
# ECS_ENGINE_AUTH_TYPE "docker" | "dockercfg" The type of auth data that is stored in the ECS_ENGINE_AUTH_DATA key.
841841
# ECS_ENGINE_AUTH_DATA
842842

843+
844+
if [[ $RUNNER_GROUP_DOC_VERSION == "V4" ]]; then
845+
ECS_INSTANCE_ATTRIBUTES="{\"sg_organization\": \"${ORGANIZATION_NAME}\",\"sg_runner_id\": \"${RUNNER_ID}\", \"sg_runner_group_id\": \"${RUNNER_GROUP_ID}\", \"sg_runner_group_signature\": \"${SG_RUNNER_GROUP_SIGNATURE}\"}"
846+
else
847+
ECS_INSTANCE_ATTRIBUTES="{\"sg_organization\": \"${ORGANIZATION_NAME}\",\"sg_runner_id\": \"${RUNNER_ID}\", \"sg_runner_group_id\": \"${RUNNER_GROUP_ID}\"}"
848+
fi
849+
843850
cat > /etc/ecs/ecs.config << EOF
844851
ECS_CLUSTER=${ECS_CLUSTER}
845852
AWS_DEFAULT_REGION=${LOCAL_AWS_DEFAULT_REGION}
846-
ECS_INSTANCE_ATTRIBUTES={"sg_organization": "${ORGANIZATION_NAME}","sg_runner_id": "${RUNNER_ID}", "sg_runner_group_id": "${RUNNER_GROUP_ID}"}
853+
ECS_INSTANCE_ATTRIBUTES=${ECS_INSTANCE_ATTRIBUTES}
847854
ECS_LOGLEVEL=info
848855
ECS_DISABLE_PRIVILEGED=false
849856
ECS_ENABLE_UNTRACKED_IMAGE_CLEANUP=true
@@ -1028,6 +1035,8 @@ fetch_organization_info() { #{{{
10281035
RUNNER_ID="$(echo "${response}" | jq -r '.data.RunnerId')"
10291036
RUNNER_GROUP_ID="$(echo "${response}" | jq -r '.data.RunnerGroupId')"
10301037
RUNNER_GROUP_ID="${RUNNER_GROUP_ID##*/}"
1038+
RUNNER_GROUP_DOC_VERSION="$(echo "${response}" | jq -r '.data.RunnerGroup.DocVersion // empty')"
1039+
SG_RUNNER_GROUP_SIGNATURE="$(echo "${response}" | jq -r '.data.RunnerGroup.RunnerGroupSignature // empty')"
10311040
# TAGS="$(echo "${response}" | jq -r '.data.Tags')"
10321041
STORAGE_ACCOUNT_NAME="$(echo "${response}" | jq -r '.data.RunnerGroup.StorageBackendConfig.azureBlobStorageAccountName // empty')"
10331042
SHARED_KEY="$(echo "${response}" | jq -r '.data.RunnerGroup.StorageBackendConfig.azureBlobStorageAccessKey // empty')"

0 commit comments

Comments
 (0)