Skip to content

Commit

Permalink
Account for trailing slash
Browse files Browse the repository at this point in the history
Fix the regex so that it will match callback URLs that end with status/.

Normally, the "/status" suffix should not be added. This is a convenience
check that allows users time to adapt their configs to the new URL.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
  • Loading branch information
gabriel-samfira committed Dec 18, 2023
1 parent 4900179 commit db259dd
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cloudconfig/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ fi
function call() {
PAYLOAD="$1"
[[ $CALLBACK_URL =~ ^(.*)/status$ ]] || CALLBACK_URL="${CALLBACK_URL}/status"
[[ $CALLBACK_URL =~ ^(.*)/status(/)?$ ]] || CALLBACK_URL="${CALLBACK_URL}/status"
curl --retry 5 --retry-delay 5 --retry-connrefused --fail -s -X POST -d "${PAYLOAD}" -H 'Accept: application/json' -H "Authorization: Bearer ${BEARER_TOKEN}" "${CALLBACK_URL}" || echo "failed to call home: exit code ($?)"
}
Expand Down Expand Up @@ -386,7 +386,7 @@ $GHRunnerGroup = "{{.GitHubRunnerGroup}}"
function Install-Runner() {
$CallbackURL="{{.CallbackURL}}"
if (!$CallbackURL.EndsWith("/status")) {
if (!($CallbackURL -match "^(.*)/status(/)?$")) {
$CallbackURL = "$CallbackURL/status"
}
Expand Down

0 comments on commit db259dd

Please sign in to comment.