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 Jul 25, 2023
1 parent db82613 commit c0631a9
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions test/e2e/framework/util.go
Expand Up @@ -466,9 +466,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 @@ -510,8 +510,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 c0631a9

Please sign in to comment.