@@ -29,7 +29,6 @@ import (
29
29
"k8s.io/apimachinery/pkg/labels"
30
30
"k8s.io/apimachinery/pkg/types"
31
31
clientset "k8s.io/client-go/kubernetes"
32
- storageutil "k8s.io/kubernetes/pkg/apis/storage/v1/util"
33
32
"k8s.io/kubernetes/pkg/volume/util"
34
33
"k8s.io/kubernetes/test/e2e/framework"
35
34
e2eskipper "k8s.io/kubernetes/test/e2e/framework/skipper"
@@ -53,6 +52,14 @@ const (
53
52
54
53
// VolumeSelectorKey is the key for volume selector.
55
54
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"
56
63
)
57
64
58
65
var (
@@ -779,7 +786,7 @@ func GetDefaultStorageClassName(c clientset.Interface) (string, error) {
779
786
}
780
787
var scName string
781
788
for _ , sc := range list .Items {
782
- if storageutil . IsDefaultAnnotation (sc .ObjectMeta ) {
789
+ if isDefaultAnnotation (sc .ObjectMeta ) {
783
790
if len (scName ) != 0 {
784
791
return "" , fmt .Errorf ("Multiple default storage classes found: %q and %q" , scName , sc .Name )
785
792
}
@@ -793,6 +800,20 @@ func GetDefaultStorageClassName(c clientset.Interface) (string, error) {
793
800
return scName , nil
794
801
}
795
802
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
+
796
817
// SkipIfNoDefaultStorageClass skips tests if no default SC can be found.
797
818
func SkipIfNoDefaultStorageClass (c clientset.Interface ) {
798
819
_ , err := GetDefaultStorageClassName (c )
0 commit comments