Skip to content

Commit

Permalink
UPSTREAM: <carry>: conditionally fill the UserAgent from the currentl…
Browse files Browse the repository at this point in the history
…y running test

OpenShift uses these function before any test is run and they cause NPE

OpenShift-Rebase-Source: 834af76
  • Loading branch information
p0lyn0mial authored and bertinatto committed Mar 6, 2024
1 parent a22a5d6 commit 4044dc3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions test/e2e/framework/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -522,9 +522,9 @@ func restclientConfig(kubeContext string) (*clientcmdapi.Config, error) {
type ClientConfigGetter func() (*restclient.Config, error)

// LoadConfig returns a config for a rest client with the UserAgent set to include the current test name.
func LoadConfig() (config *restclient.Config, err error) {
func LoadConfig(noUserAgent ...bool) (config *restclient.Config, err error) {
defer func() {
if err == nil && config != nil {
if err == nil && config != nil && len(noUserAgent) == 0 {
testDesc := ginkgo.CurrentSpecReport()
if len(testDesc.ContainerHierarchyTexts) > 0 {
testName := strings.Join(testDesc.ContainerHierarchyTexts, " ")
Expand Down Expand Up @@ -566,8 +566,8 @@ func LoadConfig() (config *restclient.Config, err error) {
}

// LoadClientset returns clientset for connecting to kubernetes clusters.
func LoadClientset() (*clientset.Clientset, error) {
config, err := LoadConfig()
func LoadClientset(noUserAgent ...bool) (*clientset.Clientset, error) {
config, err := LoadConfig(noUserAgent...)
if err != nil {
return nil, fmt.Errorf("error creating client: %v", err.Error())
}
Expand Down

0 comments on commit 4044dc3

Please sign in to comment.