mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 20:53:33 +00:00
Define const annotation variable once
Move annotation to package imported by both pkg/volume and pkg/volume/validation
This commit is contained in:
parent
5dd914382f
commit
e443277d58
@ -385,6 +385,9 @@ const (
|
|||||||
// BetaStorageClassAnnotation represents the beta/previous StorageClass annotation.
|
// BetaStorageClassAnnotation represents the beta/previous StorageClass annotation.
|
||||||
// It's currently still used and will be held for backwards compatibility
|
// It's currently still used and will be held for backwards compatibility
|
||||||
BetaStorageClassAnnotation = "volume.beta.kubernetes.io/storage-class"
|
BetaStorageClassAnnotation = "volume.beta.kubernetes.io/storage-class"
|
||||||
|
|
||||||
|
// MountOptionAnnotation defines mount option annotation used in PVs
|
||||||
|
MountOptionAnnotation = "volume.beta.kubernetes.io/mount-options"
|
||||||
)
|
)
|
||||||
|
|
||||||
// +genclient=true
|
// +genclient=true
|
||||||
|
@ -434,6 +434,9 @@ const (
|
|||||||
// BetaStorageClassAnnotation represents the beta/previous StorageClass annotation.
|
// BetaStorageClassAnnotation represents the beta/previous StorageClass annotation.
|
||||||
// It's currently still used and will be held for backwards compatibility
|
// It's currently still used and will be held for backwards compatibility
|
||||||
BetaStorageClassAnnotation = "volume.beta.kubernetes.io/storage-class"
|
BetaStorageClassAnnotation = "volume.beta.kubernetes.io/storage-class"
|
||||||
|
|
||||||
|
// MountOptionAnnotation defines mount option annotation used in PVs
|
||||||
|
MountOptionAnnotation = "volume.beta.kubernetes.io/mount-options"
|
||||||
)
|
)
|
||||||
|
|
||||||
// +genclient=true
|
// +genclient=true
|
||||||
|
@ -156,8 +156,6 @@ const (
|
|||||||
// Name of a volume in external cloud that is being provisioned and thus
|
// Name of a volume in external cloud that is being provisioned and thus
|
||||||
// should be ignored by rest of Kubernetes.
|
// should be ignored by rest of Kubernetes.
|
||||||
ProvisionedVolumeName = "placeholder-for-provisioning"
|
ProvisionedVolumeName = "placeholder-for-provisioning"
|
||||||
// Mount options annotations
|
|
||||||
MountOptionAnnotation = "volume.beta.kubernetes.io/mount-options"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// ProvisionableVolumePlugin is an extended interface of VolumePlugin and is
|
// ProvisionableVolumePlugin is an extended interface of VolumePlugin and is
|
||||||
|
@ -386,7 +386,7 @@ func MountOptionFromSpec(spec *Spec, options ...string) []string {
|
|||||||
pv := spec.PersistentVolume
|
pv := spec.PersistentVolume
|
||||||
|
|
||||||
if pv != nil {
|
if pv != nil {
|
||||||
if mo, ok := pv.Annotations[MountOptionAnnotation]; ok {
|
if mo, ok := pv.Annotations[v1.MountOptionAnnotation]; ok {
|
||||||
moList := strings.Split(mo, ",")
|
moList := strings.Split(mo, ",")
|
||||||
return JoinMountOptions(moList, options)
|
return JoinMountOptions(moList, options)
|
||||||
}
|
}
|
||||||
|
@ -362,7 +362,7 @@ func TestMountOptionFromSpec(t *testing.T) {
|
|||||||
|
|
||||||
func createVolumeSpecWithMountOption(name string, mountOptions string, spec v1.PersistentVolumeSpec) *Spec {
|
func createVolumeSpecWithMountOption(name string, mountOptions string, spec v1.PersistentVolumeSpec) *Spec {
|
||||||
annotations := map[string]string{
|
annotations := map[string]string{
|
||||||
MountOptionAnnotation: mountOptions,
|
v1.MountOptionAnnotation: mountOptions,
|
||||||
}
|
}
|
||||||
objMeta := metav1.ObjectMeta{
|
objMeta := metav1.ObjectMeta{
|
||||||
Name: name,
|
Name: name,
|
||||||
|
@ -21,9 +21,6 @@ import (
|
|||||||
"k8s.io/kubernetes/pkg/api"
|
"k8s.io/kubernetes/pkg/api"
|
||||||
)
|
)
|
||||||
|
|
||||||
// MountOptionAnnotation defines mount option annotation used in PVs
|
|
||||||
const MountOptionAnnotation = "volume.beta.kubernetes.io/mount-options"
|
|
||||||
|
|
||||||
// ValidatePersistentVolume validates PV object for plugin specific validation
|
// ValidatePersistentVolume validates PV object for plugin specific validation
|
||||||
// We can put here validations which are specific to volume types.
|
// We can put here validations which are specific to volume types.
|
||||||
func ValidatePersistentVolume(pv *api.PersistentVolume) field.ErrorList {
|
func ValidatePersistentVolume(pv *api.PersistentVolume) field.ErrorList {
|
||||||
@ -50,9 +47,9 @@ func checkMountOption(pv *api.PersistentVolume) field.ErrorList {
|
|||||||
return allErrs
|
return allErrs
|
||||||
}
|
}
|
||||||
// any other type if mount option is present lets return error
|
// any other type if mount option is present lets return error
|
||||||
if _, ok := pv.Annotations[MountOptionAnnotation]; ok {
|
if _, ok := pv.Annotations[api.MountOptionAnnotation]; ok {
|
||||||
metaField := field.NewPath("metadata")
|
metaField := field.NewPath("metadata")
|
||||||
allErrs = append(allErrs, field.Forbidden(metaField.Child("annotations", MountOptionAnnotation), "may not specify mount options for this volume type"))
|
allErrs = append(allErrs, field.Forbidden(metaField.Child("annotations", api.MountOptionAnnotation), "may not specify mount options for this volume type"))
|
||||||
}
|
}
|
||||||
return allErrs
|
return allErrs
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,7 @@ func TestValidatePersistentVolumes(t *testing.T) {
|
|||||||
|
|
||||||
func testVolumeWithMountOption(name string, namespace string, mountOptions string, spec api.PersistentVolumeSpec) *api.PersistentVolume {
|
func testVolumeWithMountOption(name string, namespace string, mountOptions string, spec api.PersistentVolumeSpec) *api.PersistentVolume {
|
||||||
annotations := map[string]string{
|
annotations := map[string]string{
|
||||||
MountOptionAnnotation: mountOptions,
|
api.MountOptionAnnotation: mountOptions,
|
||||||
}
|
}
|
||||||
objMeta := metav1.ObjectMeta{
|
objMeta := metav1.ObjectMeta{
|
||||||
Name: name,
|
Name: name,
|
||||||
|
@ -385,6 +385,9 @@ const (
|
|||||||
// BetaStorageClassAnnotation represents the beta/previous StorageClass annotation.
|
// BetaStorageClassAnnotation represents the beta/previous StorageClass annotation.
|
||||||
// It's currently still used and will be held for backwards compatibility
|
// It's currently still used and will be held for backwards compatibility
|
||||||
BetaStorageClassAnnotation = "volume.beta.kubernetes.io/storage-class"
|
BetaStorageClassAnnotation = "volume.beta.kubernetes.io/storage-class"
|
||||||
|
|
||||||
|
// MountOptionAnnotation defines mount option annotation used in PVs
|
||||||
|
MountOptionAnnotation = "volume.beta.kubernetes.io/mount-options"
|
||||||
)
|
)
|
||||||
|
|
||||||
// +genclient=true
|
// +genclient=true
|
||||||
|
@ -434,6 +434,9 @@ const (
|
|||||||
// BetaStorageClassAnnotation represents the beta/previous StorageClass annotation.
|
// BetaStorageClassAnnotation represents the beta/previous StorageClass annotation.
|
||||||
// It's currently still used and will be held for backwards compatibility
|
// It's currently still used and will be held for backwards compatibility
|
||||||
BetaStorageClassAnnotation = "volume.beta.kubernetes.io/storage-class"
|
BetaStorageClassAnnotation = "volume.beta.kubernetes.io/storage-class"
|
||||||
|
|
||||||
|
// MountOptionAnnotation defines mount option annotation used in PVs
|
||||||
|
MountOptionAnnotation = "volume.beta.kubernetes.io/mount-options"
|
||||||
)
|
)
|
||||||
|
|
||||||
// +genclient=true
|
// +genclient=true
|
||||||
|
Loading…
Reference in New Issue
Block a user