Skip to content

Commit 9bee074

Browse files
authored
Merge pull request kubernetes#89183 from andrewsykim/e2e-framework-storage-class
e2e/framework: remove direct import to pkg/apis/v1/storage/util
2 parents dfb6993 + d4d3f3d commit 9bee074

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

test/e2e/framework/pv/BUILD

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ go_library(
66
importpath = "k8s.io/kubernetes/test/e2e/framework/pv",
77
visibility = ["//visibility:public"],
88
deps = [
9-
"//pkg/apis/storage/v1/util:go_default_library",
109
"//pkg/volume/util:go_default_library",
1110
"//staging/src/k8s.io/api/core/v1:go_default_library",
1211
"//staging/src/k8s.io/apimachinery/pkg/api/errors:go_default_library",

test/e2e/framework/pv/pv.go

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import (
2929
"k8s.io/apimachinery/pkg/labels"
3030
"k8s.io/apimachinery/pkg/types"
3131
clientset "k8s.io/client-go/kubernetes"
32-
storageutil "k8s.io/kubernetes/pkg/apis/storage/v1/util"
3332
"k8s.io/kubernetes/pkg/volume/util"
3433
"k8s.io/kubernetes/test/e2e/framework"
3534
e2eskipper "k8s.io/kubernetes/test/e2e/framework/skipper"
@@ -53,6 +52,14 @@ const (
5352

5453
// VolumeSelectorKey is the key for volume selector.
5554
VolumeSelectorKey = "e2e-pv-pool"
55+
56+
// isDefaultStorageClassAnnotation represents a StorageClass annotation that
57+
// marks a class as the default StorageClass
58+
isDefaultStorageClassAnnotation = "storageclass.kubernetes.io/is-default-class"
59+
60+
// betaIsDefaultStorageClassAnnotation is the beta version of IsDefaultStorageClassAnnotation.
61+
// TODO: remove Beta when no longer used
62+
betaIsDefaultStorageClassAnnotation = "storageclass.beta.kubernetes.io/is-default-class"
5663
)
5764

5865
var (
@@ -779,7 +786,7 @@ func GetDefaultStorageClassName(c clientset.Interface) (string, error) {
779786
}
780787
var scName string
781788
for _, sc := range list.Items {
782-
if storageutil.IsDefaultAnnotation(sc.ObjectMeta) {
789+
if isDefaultAnnotation(sc.ObjectMeta) {
783790
if len(scName) != 0 {
784791
return "", fmt.Errorf("Multiple default storage classes found: %q and %q", scName, sc.Name)
785792
}
@@ -793,6 +800,20 @@ func GetDefaultStorageClassName(c clientset.Interface) (string, error) {
793800
return scName, nil
794801
}
795802

803+
// isDefaultAnnotation returns a boolean if the default storage class
804+
// annotation is set
805+
// TODO: remove Beta when no longer needed
806+
func isDefaultAnnotation(obj metav1.ObjectMeta) bool {
807+
if obj.Annotations[isDefaultStorageClassAnnotation] == "true" {
808+
return true
809+
}
810+
if obj.Annotations[betaIsDefaultStorageClassAnnotation] == "true" {
811+
return true
812+
}
813+
814+
return false
815+
}
816+
796817
// SkipIfNoDefaultStorageClass skips tests if no default SC can be found.
797818
func SkipIfNoDefaultStorageClass(c clientset.Interface) {
798819
_, err := GetDefaultStorageClassName(c)

0 commit comments

Comments
 (0)