Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define const annotation variable once #44491

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions pkg/api/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,9 @@ const (
// BetaStorageClassAnnotation represents the beta/previous StorageClass annotation.
// It's currently still used and will be held for backwards compatibility
BetaStorageClassAnnotation = "volume.beta.kubernetes.io/storage-class"

// MountOptionAnnotation defines mount option annotation used in PVs
MountOptionAnnotation = "volume.beta.kubernetes.io/mount-options"
)

// +genclient=true
Expand Down
3 changes: 3 additions & 0 deletions pkg/api/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,9 @@ const (
// BetaStorageClassAnnotation represents the beta/previous StorageClass annotation.
// It's currently still used and will be held for backwards compatibility
BetaStorageClassAnnotation = "volume.beta.kubernetes.io/storage-class"

// MountOptionAnnotation defines mount option annotation used in PVs
MountOptionAnnotation = "volume.beta.kubernetes.io/mount-options"
)

// +genclient=true
Expand Down
2 changes: 0 additions & 2 deletions pkg/volume/plugins.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,6 @@ const (
// Name of a volume in external cloud that is being provisioned and thus
// should be ignored by rest of Kubernetes.
ProvisionedVolumeName = "placeholder-for-provisioning"
// Mount options annotations
MountOptionAnnotation = "volume.beta.kubernetes.io/mount-options"
)

// ProvisionableVolumePlugin is an extended interface of VolumePlugin and is
Expand Down
2 changes: 1 addition & 1 deletion pkg/volume/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ func MountOptionFromSpec(spec *Spec, options ...string) []string {
pv := spec.PersistentVolume

if pv != nil {
if mo, ok := pv.Annotations[MountOptionAnnotation]; ok {
if mo, ok := pv.Annotations[v1.MountOptionAnnotation]; ok {
moList := strings.Split(mo, ",")
return JoinMountOptions(moList, options)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/volume/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ func TestMountOptionFromSpec(t *testing.T) {

func createVolumeSpecWithMountOption(name string, mountOptions string, spec v1.PersistentVolumeSpec) *Spec {
annotations := map[string]string{
MountOptionAnnotation: mountOptions,
v1.MountOptionAnnotation: mountOptions,
}
objMeta := metav1.ObjectMeta{
Name: name,
Expand Down
7 changes: 2 additions & 5 deletions pkg/volume/validation/pv_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ import (
"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
// We can put here validations which are specific to volume types.
func ValidatePersistentVolume(pv *api.PersistentVolume) field.ErrorList {
Expand All @@ -50,9 +47,9 @@ func checkMountOption(pv *api.PersistentVolume) field.ErrorList {
return allErrs
}
// 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")
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
}
2 changes: 1 addition & 1 deletion pkg/volume/validation/pv_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func TestValidatePersistentVolumes(t *testing.T) {

func testVolumeWithMountOption(name string, namespace string, mountOptions string, spec api.PersistentVolumeSpec) *api.PersistentVolume {
annotations := map[string]string{
MountOptionAnnotation: mountOptions,
api.MountOptionAnnotation: mountOptions,
}
objMeta := metav1.ObjectMeta{
Name: name,
Expand Down
3 changes: 3 additions & 0 deletions staging/src/k8s.io/client-go/pkg/api/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,9 @@ const (
// BetaStorageClassAnnotation represents the beta/previous StorageClass annotation.
// It's currently still used and will be held for backwards compatibility
BetaStorageClassAnnotation = "volume.beta.kubernetes.io/storage-class"

// MountOptionAnnotation defines mount option annotation used in PVs
MountOptionAnnotation = "volume.beta.kubernetes.io/mount-options"
)

// +genclient=true
Expand Down
3 changes: 3 additions & 0 deletions staging/src/k8s.io/client-go/pkg/api/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,9 @@ const (
// BetaStorageClassAnnotation represents the beta/previous StorageClass annotation.
// It's currently still used and will be held for backwards compatibility
BetaStorageClassAnnotation = "volume.beta.kubernetes.io/storage-class"

// MountOptionAnnotation defines mount option annotation used in PVs
MountOptionAnnotation = "volume.beta.kubernetes.io/mount-options"
)

// +genclient=true
Expand Down