Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit01d5b50

Browse files
committed
Add script mappings for each architecture
1 parent449ef7b commit01d5b50

File tree

1 file changed

+35
-50
lines changed

1 file changed

+35
-50
lines changed

‎provisionersdk/agent.go

Lines changed: 35 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,56 @@
11
package provisionersdk
22

3-
import"fmt"
3+
import (
4+
"fmt"
5+
"strings"
6+
)
47

58
var (
6-
// A mapping of operating-system ($GOOS) to architecture ($GOARCH)
7-
// to agent install and run script. ${DOWNLOAD_URL} is replaced
8-
// with strings.ReplaceAll() when being consumed.
9-
agentScripts=map[string]map[string]string{
10-
// On Windows, VS Code Remote requires a parent process of the
11-
// executing shell to be named "sshd", otherwise it fails. See:
12-
// https://github.com/microsoft/vscode-remote-release/issues/5699
13-
"windows": {
14-
"amd64":`$ProgressPreference = "SilentlyContinue"
15-
Invoke-WebRequest -Uri ${ACCESS_URL}bin/coder-windows-amd64.exe -OutFile $env:TEMP\sshd.exe
9+
// On Windows, VS Code Remote requires a parent process of the
10+
// executing shell to be named "sshd", otherwise it fails. See:
11+
// https://github.com/microsoft/vscode-remote-release/issues/5699
12+
windowsScript=`$ProgressPreference = "SilentlyContinue"
13+
Invoke-WebRequest -Uri ${ACCESS_URL}bin/coder-windows-${ARCH}.exe -OutFile $env:TEMP\sshd.exe
1614
Set-MpPreference -DisableRealtimeMonitoring $true -ExclusionPath $env:TEMP\sshd.exe
1715
$env:CODER_AGENT_AUTH = "${AUTH_TYPE}"
1816
$env:CODER_AGENT_URL = "${ACCESS_URL}"
19-
Start-Process -FilePath $env:TEMP\sshd.exe -ArgumentList "agent" -PassThru`,
20-
"arm64":`$ProgressPreference = "SilentlyContinue"
21-
Invoke-WebRequest -Uri ${ACCESS_URL}bin/coder-windows-arm64.exe -OutFile $env:TEMP\sshd.exe
22-
Set-MpPreference -DisableRealtimeMonitoring $true -ExclusionPath $env:TEMP\sshd.exe
23-
$env:CODER_AGENT_AUTH = "${AUTH_TYPE}"
24-
$env:CODER_AGENT_URL = "${ACCESS_URL}"
25-
Start-Process -FilePath $env:TEMP\sshd.exe -ArgumentList "agent" -PassThru`,
26-
},
27-
"linux": {
28-
"amd64":`#!/usr/bin/env sh
29-
set -eu pipefail
30-
export BINARY_LOCATION=$(mktemp -d -t tmp.coderXXXXX)/coder
31-
curl -fsSL ${ACCESS_URL}bin/coder-linux-amd64 -o $BINARY_LOCATION
32-
chmod +x $BINARY_LOCATION
33-
export CODER_AGENT_AUTH="${AUTH_TYPE}"
34-
export CODER_AGENT_URL="${ACCESS_URL}"
35-
exec $BINARY_LOCATION agent`,
36-
"arm64":`#!/usr/bin/env sh
17+
Start-Process -FilePath $env:TEMP\sshd.exe -ArgumentList "agent" -PassThru`
18+
19+
linuxScript=`#!/usr/bin/env sh
3720
set -eu pipefail
3821
export BINARY_LOCATION=$(mktemp -d -t tmp.coderXXXXX)/coder
39-
curl -fsSL ${ACCESS_URL}bin/coder-linux-arm64 -o $BINARY_LOCATION
22+
curl -fsSL ${ACCESS_URL}bin/coder-linux-${ARCH} -o $BINARY_LOCATION
4023
chmod +x $BINARY_LOCATION
4124
export CODER_AGENT_AUTH="${AUTH_TYPE}"
4225
export CODER_AGENT_URL="${ACCESS_URL}"
43-
exec $BINARY_LOCATION agent`,
44-
"armv7":`#!/usr/bin/env sh
26+
exec $BINARY_LOCATION agent`
27+
28+
darwinScript=`#!/usr/bin/env sh
4529
set -eu pipefail
4630
export BINARY_LOCATION=$(mktemp -d -t tmp.coderXXXXX)/coder
47-
curl -fsSL ${ACCESS_URL}bin/coder-linux-armv7 -o $BINARY_LOCATION
31+
curl -fsSL ${ACCESS_URL}bin/coder-darwin-${ARCH} -o $BINARY_LOCATION
4832
chmod +x $BINARY_LOCATION
4933
export CODER_AGENT_AUTH="${AUTH_TYPE}"
5034
export CODER_AGENT_URL="${ACCESS_URL}"
51-
exec $BINARY_LOCATION agent`,
35+
exec $BINARY_LOCATION agent`
36+
37+
// A mapping of operating-system ($GOOS) to architecture ($GOARCH)
38+
// to agent install and run script. ${DOWNLOAD_URL} is replaced
39+
// with strings.ReplaceAll() when being consumed. ${ARCH} is replaced
40+
// with the architecture when being provided.
41+
agentScripts=map[string]map[string]string{
42+
"windows": {
43+
"amd64":windowsScript,
44+
"arm64":windowsScript,
45+
},
46+
"linux": {
47+
"amd64":linuxScript,
48+
"arm64":linuxScript,
49+
"armv7":linuxScript,
5250
},
5351
"darwin": {
54-
"amd64":`#!/usr/bin/env sh
55-
set -eu pipefail
56-
export BINARY_LOCATION=$(mktemp -d -t tmp.coderXXXXX)/coder
57-
curl -fsSL ${ACCESS_URL}bin/coder-darwin-amd64 -o $BINARY_LOCATION
58-
chmod +x $BINARY_LOCATION
59-
export CODER_AGENT_AUTH="${AUTH_TYPE}"
60-
export CODER_AGENT_URL="${ACCESS_URL}"
61-
exec $BINARY_LOCATION agent`,
62-
"arm64":`#!/usr/bin/env sh
63-
set -eu pipefail
64-
export BINARY_LOCATION=$(mktemp -d -t tmp.coderXXXXX)/coder
65-
curl -fsSL ${ACCESS_URL}bin/coder-darwin-arm64 -o $BINARY_LOCATION
66-
chmod +x $BINARY_LOCATION
67-
export CODER_AGENT_AUTH="${AUTH_TYPE}"
68-
export CODER_AGENT_URL="${ACCESS_URL}"
69-
exec $BINARY_LOCATION agent`,
52+
"amd64":darwinScript,
53+
"arm64":darwinScript,
7054
},
7155
}
7256
)
@@ -78,6 +62,7 @@ func AgentScriptEnv() map[string]string {
7862
env:=map[string]string{}
7963
foroperatingSystem,scripts:=rangeagentScripts {
8064
forarchitecture,script:=rangescripts {
65+
script:=strings.ReplaceAll(script,"${ARCH}",architecture)
8166
env[fmt.Sprintf("CODER_AGENT_SCRIPT_%s_%s",operatingSystem,architecture)]=script
8267
}
8368
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp