Skip to content

Commit

Permalink
Ensure all string slice args get whitespace cleaned
Browse files Browse the repository at this point in the history
  • Loading branch information
moskyb committed Oct 2, 2024
1 parent ee70db6 commit 3338f3d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
5 changes: 0 additions & 5 deletions clicommand/oidc_request_token.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"fmt"
"net/http"
"strings"
"time"

"github.com/buildkite/agent/v3/api"
Expand Down Expand Up @@ -111,10 +110,6 @@ var OIDCRequestTokenCommand = cli.Command{
return fmt.Errorf("lifetime %d must be a non-negative integer.", cfg.Lifetime)
}

for i, claim := range cfg.Claims {
cfg.Claims[i] = strings.TrimSpace(claim)
}

// Create the API client
client := api.NewClient(l, loadAPIClientConfig(cfg, "AgentAccessToken"))

Expand Down
6 changes: 5 additions & 1 deletion cliconfig/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,11 @@ func (l Loader) setFieldValueFromCLI(fieldName string, cliName string) error {
case reflect.String:
value = configFileValue
case reflect.Slice:
value = strings.Split(configFileValue, ",")
valueSlice := strings.Split(configFileValue, ",")
for i, e := range valueSlice {
valueSlice[i] = strings.TrimSpace(e)
}
value = valueSlice
case reflect.Bool:
value, _ = strconv.ParseBool(configFileValue)
case reflect.Int:
Expand Down

0 comments on commit 3338f3d

Please sign in to comment.