cleanup: avoid double import of kubernetes library in e2e utils

Signed-off-by: Humble Chirammal <hchiramm@redhat.com>
This commit is contained in:
Humble Chirammal 2020-06-11 13:41:39 +05:30 committed by mergify[bot]
parent e9082768b6
commit dcbf71dd5d

View File

@ -24,7 +24,6 @@ import (
"k8s.io/apimachinery/pkg/util/wait" "k8s.io/apimachinery/pkg/util/wait"
utilyaml "k8s.io/apimachinery/pkg/util/yaml" utilyaml "k8s.io/apimachinery/pkg/util/yaml"
"k8s.io/client-go/kubernetes" "k8s.io/client-go/kubernetes"
clientset "k8s.io/client-go/kubernetes"
"k8s.io/kubernetes/pkg/client/conditions" "k8s.io/kubernetes/pkg/client/conditions"
"k8s.io/kubernetes/test/e2e/framework" "k8s.io/kubernetes/test/e2e/framework"
e2elog "k8s.io/kubernetes/test/e2e/framework/log" e2elog "k8s.io/kubernetes/test/e2e/framework/log"
@ -65,7 +64,7 @@ func initResouces() {
vaultAddr = fmt.Sprintf("http://vault.%s.svc.cluster.local:8200", cephCSINamespace) vaultAddr = fmt.Sprintf("http://vault.%s.svc.cluster.local:8200", cephCSINamespace)
} }
func createNamespace(c clientset.Interface, name string) error { func createNamespace(c kubernetes.Interface, name string) error {
timeout := time.Duration(deployTimeout) * time.Minute timeout := time.Duration(deployTimeout) * time.Minute
ns := &v1.Namespace{ ns := &v1.Namespace{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
@ -93,7 +92,7 @@ func createNamespace(c clientset.Interface, name string) error {
}) })
} }
func deleteNamespace(c clientset.Interface, name string) error { func deleteNamespace(c kubernetes.Interface, name string) error {
timeout := time.Duration(deployTimeout) * time.Minute timeout := time.Duration(deployTimeout) * time.Minute
err := c.CoreV1().Namespaces().Delete(context.TODO(), name, metav1.DeleteOptions{}) err := c.CoreV1().Namespaces().Delete(context.TODO(), name, metav1.DeleteOptions{})
if err != nil && !apierrs.IsNotFound(err) { if err != nil && !apierrs.IsNotFound(err) {
@ -123,7 +122,7 @@ func replaceNamespaceInTemplate(filePath string) (string, error) {
return strings.ReplaceAll(string(read), "namespace: default", fmt.Sprintf("namespace: %s", cephCSINamespace)), nil return strings.ReplaceAll(string(read), "namespace: default", fmt.Sprintf("namespace: %s", cephCSINamespace)), nil
} }
func waitForDaemonSets(name, ns string, c clientset.Interface, t int) error { func waitForDaemonSets(name, ns string, c kubernetes.Interface, t int) error {
timeout := time.Duration(t) * time.Minute timeout := time.Duration(t) * time.Minute
start := time.Now() start := time.Now()
e2elog.Logf("Waiting up to %v for all daemonsets in namespace '%s' to start", timeout, ns) e2elog.Logf("Waiting up to %v for all daemonsets in namespace '%s' to start", timeout, ns)
@ -153,7 +152,7 @@ func waitForDaemonSets(name, ns string, c clientset.Interface, t int) error {
// Waits for the deployment to complete. // Waits for the deployment to complete.
func waitForDeploymentComplete(name, ns string, c clientset.Interface, t int) error { func waitForDeploymentComplete(name, ns string, c kubernetes.Interface, t int) error {
var ( var (
deployment *apps.Deployment deployment *apps.Deployment
reason string reason string
@ -1078,7 +1077,7 @@ func createNodeLabel(f *framework.Framework, labelKey, labelValue string) {
} }
} }
func deleteNodeLabel(c clientset.Interface, labelKey string) { func deleteNodeLabel(c kubernetes.Interface, labelKey string) {
nodes, err := c.CoreV1().Nodes().List(context.TODO(), metav1.ListOptions{}) nodes, err := c.CoreV1().Nodes().List(context.TODO(), metav1.ListOptions{})
Expect(err).Should(BeNil()) Expect(err).Should(BeNil())
for i := range nodes.Items { for i := range nodes.Items {
@ -1086,7 +1085,7 @@ func deleteNodeLabel(c clientset.Interface, labelKey string) {
} }
} }
func checkNodeHasLabel(c clientset.Interface, labelKey, labelValue string) { func checkNodeHasLabel(c kubernetes.Interface, labelKey, labelValue string) {
nodes, err := c.CoreV1().Nodes().List(context.TODO(), metav1.ListOptions{}) nodes, err := c.CoreV1().Nodes().List(context.TODO(), metav1.ListOptions{})
Expect(err).Should(BeNil()) Expect(err).Should(BeNil())
for i := range nodes.Items { for i := range nodes.Items {
@ -1156,7 +1155,7 @@ func checkPVCCSIJournalInPool(f *framework.Framework, pvc *v1.PersistentVolumeCl
} }
// getBoundPV returns a PV details. // getBoundPV returns a PV details.
func getBoundPV(client clientset.Interface, pvc *v1.PersistentVolumeClaim) (*v1.PersistentVolume, error) { func getBoundPV(client kubernetes.Interface, pvc *v1.PersistentVolumeClaim) (*v1.PersistentVolume, error) {
// Get new copy of the claim // Get new copy of the claim
claim, err := client.CoreV1().PersistentVolumeClaims(pvc.Namespace).Get(context.TODO(), pvc.Name, metav1.GetOptions{}) claim, err := client.CoreV1().PersistentVolumeClaims(pvc.Namespace).Get(context.TODO(), pvc.Name, metav1.GetOptions{})
if err != nil { if err != nil {