Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prow: Set proper user-agent in config #21067

Merged
merged 1 commit into from
Feb 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions prow/kube/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ go_library(
"//prow/apis/prowjobs/v1:go_default_library",
"//prow/client/clientset/versioned:go_default_library",
"//prow/client/clientset/versioned/typed/prowjobs/v1:go_default_library",
"//prow/version:go_default_library",
"@com_github_prometheus_client_golang//prometheus:go_default_library",
"@com_github_sirupsen_logrus//:go_default_library",
"@io_k8s_api//core/v1:go_default_library",
Expand Down
5 changes: 5 additions & 0 deletions prow/kube/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import (
"github.com/sirupsen/logrus"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"

"k8s.io/test-infra/prow/version"
)

func kubeConfigs(kubeconfig string) (map[string]rest.Config, string, error) {
Expand All @@ -48,6 +50,7 @@ func kubeConfigs(kubeconfig string) (map[string]rest.Config, string, error) {
if err != nil {
return nil, "", fmt.Errorf("create %s client: %v", context, err)
}
contextCfg.UserAgent = version.UserAgent()
configs[context] = *contextCfg
logrus.Infof("Parsed kubeconfig context: %s", context)
}
Expand Down Expand Up @@ -86,6 +89,8 @@ func LoadClusterConfigs(kubeconfig, projectedTokenFile string) (map[string]rest.
localCfg, err := rest.InClusterConfig()
if err != nil {
logrus.WithError(err).Warn("Could not create in-cluster config (expected when running outside the cluster).")
} else {
localCfg.UserAgent = version.UserAgent()
}
if localCfg != nil && projectedTokenFile != "" {
localCfg.BearerToken = ""
Expand Down