mirror of
https://github.com/optim-enterprises-bv/kubernetes.git
synced 2025-10-30 01:42:48 +00:00
Move PV/PVC annotations to PV/PVC types.
They aren't part of storage.k8s.io/v1 or v1beta1 API. Also move associated *GetClass functions.
This commit is contained in:
@@ -96,7 +96,7 @@ func (c *claimDefaulterPlugin) Admit(a admission.Attributes) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
if storageutil.HasStorageClassAnnotation(pvc.ObjectMeta) {
|
||||
if api.PersistentVolumeClaimHasClass(pvc) {
|
||||
// The user asked for a class.
|
||||
return nil
|
||||
}
|
||||
@@ -116,7 +116,7 @@ func (c *claimDefaulterPlugin) Admit(a admission.Attributes) error {
|
||||
if pvc.ObjectMeta.Annotations == nil {
|
||||
pvc.ObjectMeta.Annotations = map[string]string{}
|
||||
}
|
||||
pvc.Annotations[storageutil.StorageClassAnnotation] = def.Name
|
||||
pvc.Annotations[api.BetaStorageClassAnnotation] = def.Name
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apiserver/pkg/admission"
|
||||
"k8s.io/kubernetes/pkg/api"
|
||||
"k8s.io/kubernetes/pkg/api/v1"
|
||||
"k8s.io/kubernetes/pkg/apis/storage"
|
||||
storageutil "k8s.io/kubernetes/pkg/apis/storage/util"
|
||||
informers "k8s.io/kubernetes/pkg/client/informers/informers_generated/internalversion"
|
||||
@@ -100,7 +101,7 @@ func TestAdmission(t *testing.T) {
|
||||
Name: "claimWithClass",
|
||||
Namespace: "ns",
|
||||
Annotations: map[string]string{
|
||||
storageutil.StorageClassAnnotation: "foo",
|
||||
v1.BetaStorageClassAnnotation: "foo",
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -112,7 +113,7 @@ func TestAdmission(t *testing.T) {
|
||||
Name: "claimWithEmptyClass",
|
||||
Namespace: "ns",
|
||||
Annotations: map[string]string{
|
||||
storageutil.StorageClassAnnotation: "",
|
||||
v1.BetaStorageClassAnnotation: "",
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -222,7 +223,7 @@ func TestAdmission(t *testing.T) {
|
||||
|
||||
class := ""
|
||||
if claim.Annotations != nil {
|
||||
if value, ok := claim.Annotations[storageutil.StorageClassAnnotation]; ok {
|
||||
if value, ok := claim.Annotations[v1.BetaStorageClassAnnotation]; ok {
|
||||
class = value
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user