Skip to content

Commit

Permalink
feat(cli): allow users to specify AGENT_URL with ${BIN_NAME} argument
Browse files Browse the repository at this point in the history
The arg will be substituted with the agent binary name to allow for
more customized Agent URLs like presigned s3 URLs
  • Loading branch information
pascalbreuninger committed Jun 3, 2024
1 parent 6f142a3 commit 53f1d78
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions pkg/inject/download_urls.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ package inject

import (
"net/url"
"strings"
)

const AmdUrl = "devpod-linux-amd64"
const ArmUrl = "devpod-linux-arm64"
const BinNamePlaceholder = "${BIN_NAME}"

type DownloadURLs struct {
Base string
Expand All @@ -14,8 +16,17 @@ type DownloadURLs struct {
}

func NewDownloadURLs(baseUrl string) *DownloadURLs {
amdUrl, _ := url.JoinPath(baseUrl, AmdUrl)
armUrl, _ := url.JoinPath(baseUrl, ArmUrl)
var amdUrl, armUrl string

// replace ${BIN_NAME} with binary name
if strings.Contains(baseUrl, BinNamePlaceholder) {
baseUrl = strings.TrimSuffix(baseUrl, "/")
amdUrl = strings.Replace(baseUrl, BinNamePlaceholder, AmdUrl, 1)
armUrl = strings.Replace(baseUrl, BinNamePlaceholder, ArmUrl, 1)
} else {
amdUrl, _ = url.JoinPath(baseUrl, AmdUrl)
armUrl, _ = url.JoinPath(baseUrl, ArmUrl)
}

return &DownloadURLs{
Base: baseUrl,
Expand Down

0 comments on commit 53f1d78

Please sign in to comment.