Merge pull request #110707 from wongearl/fix-package-importe

fix "k8s.io/client-go/rest" is being imported more than once,optimize code
This commit is contained in:
Kubernetes Prow Robot 2022-06-22 00:35:44 -07:00 committed by GitHub
commit 10486a7331
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -53,7 +53,6 @@ import (
utilfeature "k8s.io/apiserver/pkg/util/feature" utilfeature "k8s.io/apiserver/pkg/util/feature"
"k8s.io/client-go/dynamic" "k8s.io/client-go/dynamic"
clientset "k8s.io/client-go/kubernetes" clientset "k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
restclient "k8s.io/client-go/rest" restclient "k8s.io/client-go/rest"
"k8s.io/client-go/tools/cache" "k8s.io/client-go/tools/cache"
"k8s.io/client-go/tools/clientcmd" "k8s.io/client-go/tools/clientcmd"
@ -492,7 +491,7 @@ func LoadConfig() (config *restclient.Config, err error) {
testDesc := ginkgo.CurrentGinkgoTestDescription() testDesc := ginkgo.CurrentGinkgoTestDescription()
if len(testDesc.ComponentTexts) > 0 { if len(testDesc.ComponentTexts) > 0 {
componentTexts := strings.Join(testDesc.ComponentTexts, " ") componentTexts := strings.Join(testDesc.ComponentTexts, " ")
config.UserAgent = fmt.Sprintf("%s -- %s", rest.DefaultKubernetesUserAgent(), componentTexts) config.UserAgent = fmt.Sprintf("%s -- %s", restclient.DefaultKubernetesUserAgent(), componentTexts)
} }
} }
}() }()
@ -1357,7 +1356,7 @@ func PrettyPrintJSON(metrics interface{}) string {
Logf("Error indenting: %v", err) Logf("Error indenting: %v", err)
return "" return ""
} }
return string(formatted.Bytes()) return formatted.String()
} }
// taintExists checks if the given taint exists in list of taints. Returns true if exists false otherwise. // taintExists checks if the given taint exists in list of taints. Returns true if exists false otherwise.
@ -1422,7 +1421,7 @@ retriesLoop:
break actualWatchEventsLoop break actualWatchEventsLoop
} }
} }
if foundExpectedWatchEvent == false { if !foundExpectedWatchEvent {
errs.Insert(fmt.Sprintf("Watch event %v not found", expectedWatchEvent.Type)) errs.Insert(fmt.Sprintf("Watch event %v not found", expectedWatchEvent.Type))
} }
totalValidWatchEvents++ totalValidWatchEvents++