Skip to content

Commit 53f1d78

Browse files
feat(cli): allow users to specify AGENT_URL with ${BIN_NAME} argument
The arg will be substituted with the agent binary name to allow for more customized Agent URLs like presigned s3 URLs
1 parent 6f142a3 commit 53f1d78

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

pkg/inject/download_urls.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@ package inject
22

33
import (
44
"net/url"
5+
"strings"
56
)
67

78
const AmdUrl = "devpod-linux-amd64"
89
const ArmUrl = "devpod-linux-arm64"
10+
const BinNamePlaceholder = "${BIN_NAME}"
911

1012
type DownloadURLs struct {
1113
Base string
@@ -14,8 +16,17 @@ type DownloadURLs struct {
1416
}
1517

1618
func NewDownloadURLs(baseUrl string) *DownloadURLs {
17-
amdUrl, _ := url.JoinPath(baseUrl, AmdUrl)
18-
armUrl, _ := url.JoinPath(baseUrl, ArmUrl)
19+
var amdUrl, armUrl string
20+
21+
// replace ${BIN_NAME} with binary name
22+
if strings.Contains(baseUrl, BinNamePlaceholder) {
23+
baseUrl = strings.TrimSuffix(baseUrl, "/")
24+
amdUrl = strings.Replace(baseUrl, BinNamePlaceholder, AmdUrl, 1)
25+
armUrl = strings.Replace(baseUrl, BinNamePlaceholder, ArmUrl, 1)
26+
} else {
27+
amdUrl, _ = url.JoinPath(baseUrl, AmdUrl)
28+
armUrl, _ = url.JoinPath(baseUrl, ArmUrl)
29+
}
1930

2031
return &DownloadURLs{
2132
Base: baseUrl,

0 commit comments

Comments
 (0)