Skip to content

Commit 07eb239

Browse files
p0lyn0mialbertinatto
authored andcommitted
UPSTREAM: <carry>: conditionally fill the UserAgent from the currently running test
OpenShift uses these function before any test is run and they cause NPE OpenShift-Rebase-Source: 834af76
1 parent 0a450f4 commit 07eb239

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

test/e2e/framework/util.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -497,9 +497,9 @@ func restclientConfig(kubeContext string) (*clientcmdapi.Config, error) {
497497
type ClientConfigGetter func() (*restclient.Config, error)
498498

499499
// LoadConfig returns a config for a rest client with the UserAgent set to include the current test name.
500-
func LoadConfig() (config *restclient.Config, err error) {
500+
func LoadConfig(noUserAgent ...bool) (config *restclient.Config, err error) {
501501
defer func() {
502-
if err == nil && config != nil {
502+
if err == nil && config != nil && len(noUserAgent) == 0 {
503503
testDesc := ginkgo.CurrentSpecReport()
504504
if len(testDesc.ContainerHierarchyTexts) > 0 {
505505
testName := strings.Join(testDesc.ContainerHierarchyTexts, " ")
@@ -541,8 +541,8 @@ func LoadConfig() (config *restclient.Config, err error) {
541541
}
542542

543543
// LoadClientset returns clientset for connecting to kubernetes clusters.
544-
func LoadClientset() (*clientset.Clientset, error) {
545-
config, err := LoadConfig()
544+
func LoadClientset(noUserAgent ...bool) (*clientset.Clientset, error) {
545+
config, err := LoadConfig(noUserAgent...)
546546
if err != nil {
547547
return nil, fmt.Errorf("error creating client: %v", err.Error())
548548
}

0 commit comments

Comments
 (0)