From 60cb0d3cc198828e3538f302cdd4771ebc6ce13f Mon Sep 17 00:00:00 2001 From: Andrew Sy Kim Date: Tue, 17 Mar 2020 16:07:42 -0400 Subject: [PATCH 1/2] e2e/framework: remove direct import to pkg/apis/v1/storage/util Signed-off-by: Andrew Sy Kim --- test/e2e/framework/pv/BUILD | 1 - test/e2e/framework/pv/pv.go | 25 +++++++++++++++++++++++-- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/test/e2e/framework/pv/BUILD b/test/e2e/framework/pv/BUILD index 74089a42c69..84a09aa6bd8 100644 --- a/test/e2e/framework/pv/BUILD +++ b/test/e2e/framework/pv/BUILD @@ -6,7 +6,6 @@ go_library( importpath = "k8s.io/kubernetes/test/e2e/framework/pv", visibility = ["//visibility:public"], deps = [ - "//pkg/apis/storage/v1/util:go_default_library", "//pkg/volume/util:go_default_library", "//staging/src/k8s.io/api/core/v1:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/api/errors:go_default_library", diff --git a/test/e2e/framework/pv/pv.go b/test/e2e/framework/pv/pv.go index 7741db13136..b020b1da427 100644 --- a/test/e2e/framework/pv/pv.go +++ b/test/e2e/framework/pv/pv.go @@ -29,7 +29,6 @@ import ( "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/types" clientset "k8s.io/client-go/kubernetes" - storageutil "k8s.io/kubernetes/pkg/apis/storage/v1/util" "k8s.io/kubernetes/pkg/volume/util" "k8s.io/kubernetes/test/e2e/framework" e2eskipper "k8s.io/kubernetes/test/e2e/framework/skipper" @@ -53,6 +52,14 @@ const ( // VolumeSelectorKey is the key for volume selector. VolumeSelectorKey = "e2e-pv-pool" + + // IsDefaultStorageClassAnnotation represents a StorageClass annotation that + // marks a class as the default StorageClass + IsDefaultStorageClassAnnotation = "storageclass.kubernetes.io/is-default-class" + + // BetaIsDefaultStorageClassAnnotation is the beta version of IsDefaultStorageClassAnnotation. + // TODO: remove Beta when no longer used + BetaIsDefaultStorageClassAnnotation = "storageclass.beta.kubernetes.io/is-default-class" ) var ( @@ -779,7 +786,7 @@ func GetDefaultStorageClassName(c clientset.Interface) (string, error) { } var scName string for _, sc := range list.Items { - if storageutil.IsDefaultAnnotation(sc.ObjectMeta) { + if isDefaultAnnotation(sc.ObjectMeta) { if len(scName) != 0 { return "", fmt.Errorf("Multiple default storage classes found: %q and %q", scName, sc.Name) } @@ -793,6 +800,20 @@ func GetDefaultStorageClassName(c clientset.Interface) (string, error) { return scName, nil } +// isDefaultAnnotation returns a boolean if the default storage class +// annotation is set +// TODO: remove Beta when no longer needed +func isDefaultAnnotation(obj metav1.ObjectMeta) bool { + if obj.Annotations[IsDefaultStorageClassAnnotation] == "true" { + return true + } + if obj.Annotations[BetaIsDefaultStorageClassAnnotation] == "true" { + return true + } + + return false +} + // SkipIfNoDefaultStorageClass skips tests if no default SC can be found. func SkipIfNoDefaultStorageClass(c clientset.Interface) { _, err := GetDefaultStorageClassName(c) From d4d3f3dda8a39224190e543bedf402a19f9cd000 Mon Sep 17 00:00:00 2001 From: Andrew Sy Kim Date: Tue, 17 Mar 2020 16:40:23 -0400 Subject: [PATCH 2/2] e2e/framework: copied constants for default storage class annotations should be unexported Signed-off-by: Andrew Sy Kim --- test/e2e/framework/pv/pv.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/e2e/framework/pv/pv.go b/test/e2e/framework/pv/pv.go index b020b1da427..a6ff32f5989 100644 --- a/test/e2e/framework/pv/pv.go +++ b/test/e2e/framework/pv/pv.go @@ -53,13 +53,13 @@ const ( // VolumeSelectorKey is the key for volume selector. VolumeSelectorKey = "e2e-pv-pool" - // IsDefaultStorageClassAnnotation represents a StorageClass annotation that + // isDefaultStorageClassAnnotation represents a StorageClass annotation that // marks a class as the default StorageClass - IsDefaultStorageClassAnnotation = "storageclass.kubernetes.io/is-default-class" + isDefaultStorageClassAnnotation = "storageclass.kubernetes.io/is-default-class" - // BetaIsDefaultStorageClassAnnotation is the beta version of IsDefaultStorageClassAnnotation. + // betaIsDefaultStorageClassAnnotation is the beta version of IsDefaultStorageClassAnnotation. // TODO: remove Beta when no longer used - BetaIsDefaultStorageClassAnnotation = "storageclass.beta.kubernetes.io/is-default-class" + betaIsDefaultStorageClassAnnotation = "storageclass.beta.kubernetes.io/is-default-class" ) var ( @@ -804,10 +804,10 @@ func GetDefaultStorageClassName(c clientset.Interface) (string, error) { // annotation is set // TODO: remove Beta when no longer needed func isDefaultAnnotation(obj metav1.ObjectMeta) bool { - if obj.Annotations[IsDefaultStorageClassAnnotation] == "true" { + if obj.Annotations[isDefaultStorageClassAnnotation] == "true" { return true } - if obj.Annotations[BetaIsDefaultStorageClassAnnotation] == "true" { + if obj.Annotations[betaIsDefaultStorageClassAnnotation] == "true" { return true }