Skip to content

Commit

Permalink
Merge pull request #21067 from alvaroaleman/set-manager
Browse files Browse the repository at this point in the history
Prow: Set proper user-agent in config
  • Loading branch information
k8s-ci-robot committed Feb 28, 2021
2 parents a2740c4 + 36b2f8c commit 1383067
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
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

0 comments on commit 1383067

Please sign in to comment.