Skip to content

Commit ec60825

Browse files
committed
Validate the selected http client profile and keep a list
1 parent 1d203b9 commit ec60825

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

clicommand/agent_start.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
"github.com/buildkite/agent/v3/api"
2727
"github.com/buildkite/agent/v3/core"
2828
"github.com/buildkite/agent/v3/internal/agentapi"
29+
"github.com/buildkite/agent/v3/internal/agenthttp"
2930
"github.com/buildkite/agent/v3/internal/awslib"
3031
awssigner "github.com/buildkite/agent/v3/internal/cryptosigner/aws"
3132
"github.com/buildkite/agent/v3/internal/experiments"
@@ -1103,6 +1104,10 @@ var AgentStartCommand = cli.Command{
11031104

11041105
l.Info("Using http client profile: %s", cfg.HTTPClientProfile)
11051106

1107+
if !slices.Contains(agenthttp.ValidHTTPClientProfiles, cfg.HTTPClientProfile) {
1108+
l.Fatal("HTTP client profile %s is not in list of valid profiles: %v", cfg.HTTPClientProfile, agenthttp.ValidHTTPClientProfiles)
1109+
}
1110+
11061111
if len(cfg.AllowedRepositories) > 0 {
11071112
agentConf.AllowedRepositories = make([]*regexp.Regexp, 0, len(cfg.AllowedRepositories))
11081113
for _, v := range cfg.AllowedRepositories {

clicommand/global.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ var (
4545

4646
HTTPClientProfileFlag = cli.StringFlag{
4747
Name: "http-client-profile",
48-
Usage: "Enable a http client profile, either standard, gcp or stdlib",
49-
Value: "standard",
48+
Usage: "Enable a http client profile, either default or stdlib",
49+
Value: "default",
5050
EnvVar: "BUILDKITE_AGENT_HTTP_CLIENT_PROFILE",
5151
}
5252

internal/agenthttp/client.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ import (
1111
"golang.org/x/net/http2"
1212
)
1313

14+
var (
15+
ValidHTTPClientProfiles = []string{"stdlib", "default"}
16+
)
17+
1418
// NewClient creates a HTTP client. Note that the default timeout is 60 seconds;
1519
// for some use cases (e.g. artifact operations) use [WithNoTimeout].
1620
func NewClient(opts ...ClientOption) *http.Client {
@@ -47,6 +51,8 @@ func NewClient(opts ...ClientOption) *http.Client {
4751
}
4852
}
4953

54+
// fall back to the default http client profile
55+
5056
cacheKey := transportCacheKey{
5157
AllowHTTP2: conf.AllowHTTP2,
5258
TLSConfig: conf.TLSConfig,

0 commit comments

Comments
 (0)