Skip to content

Commit

Permalink
add User-Agent when CLI sends requests API requests
Browse files Browse the repository at this point in the history
  • Loading branch information
dejanzele committed Oct 18, 2024
1 parent 86382dc commit 0edd911
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions cmd/kubectl-testkube/commands/common/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import (
"github.com/kubeshop/testkube/pkg/cloudlogin"
)

const UserAgentCLI = "testkube-cli"

// GetClient returns api client
func GetClient(cmd *cobra.Command) (client.Client, string, error) {
clientType := cmd.Flag("client").Value.String()
Expand All @@ -35,6 +37,11 @@ func GetClient(cmd *cobra.Command) (client.Client, string, error) {
return nil, "", fmt.Errorf("parsing flag value %w", err)
}

if headers == nil {
headers = make(map[string]string)
}
headers["User-Agent"] = UserAgentCLI

options := client.Options{
Namespace: namespace,
ApiUri: apiURI,
Expand Down

0 comments on commit 0edd911

Please sign in to comment.