Skip to content

Commit 8e17254

Browse files
authored
fix: Add test for wrapping init script with single quotes (#2979)
This ensures our initialization script works with single uotes.
1 parent b5f5e90 commit 8e17254

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

provisionersdk/agent_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ func TestAgentScript(t *testing.T) {
4646
}
4747
script = strings.ReplaceAll(script, "${ACCESS_URL}", srvURL.String()+"/")
4848
script = strings.ReplaceAll(script, "${AUTH_TYPE}", "token")
49-
output, err := exec.Command("sh", "-c", script).CombinedOutput()
49+
// This is intentionally ran in single quotes to mimic how a customer may
50+
// embed our script. Our scripts should not include any single quotes.
51+
// nolint:gosec
52+
output, err := exec.Command("sh", "-c", "sh -c '"+script+"'").CombinedOutput()
5053
t.Log(string(output))
5154
require.NoError(t, err)
5255
// Ignore debug output from `set -x`, we're only interested in the last line.

provisionersdk/scripts/bootstrap_linux.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ cd "$BINARY_DIR"
1616
# This could fail for a number of reasons, many of which are likely transient.
1717
# So just keep trying!
1818
while :; do
19-
# Try a number of different download tools, as we don't know what we'll
20-
# have available
19+
# Try a number of different download tools, as we don not know what we
20+
# will have available.
2121
status=""
2222
if command -v curl >/dev/null 2>&1; then
2323
curl -fsSL --compressed "${BINARY_URL}" -o "${BINARY_NAME}" && break

provisionersdk/scripts/bootstrap_windows.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Sleep for a while in case the underlying provider deletes the resource on error.
22
trap {
3-
Write-Error '=== Agent script exited with non-zero code. Sleeping 24h to preserve logs...'
3+
Write-Error "=== Agent script exited with non-zero code. Sleeping 24h to preserve logs..."
44
Start-Sleep -Seconds 86400
55
}
66

@@ -25,7 +25,7 @@ while ($true) {
2525
}
2626
}
2727

28-
# If the below fails, retrying probably won't help.
28+
# If the below fails, retrying probably will not help.
2929
Set-MpPreference -DisableRealtimeMonitoring $true -ExclusionPath $env:TEMP\sshd.exe
3030
$env:CODER_AGENT_AUTH = "${AUTH_TYPE}"
3131
$env:CODER_AGENT_URL = "${ACCESS_URL}"

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy