mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-08 11:38:15 +00:00
rename function for dropping disabled fields
The function should indicate it is specific for dropping spec fields.
This commit is contained in:
parent
d6e525877b
commit
a31fee98f0
@ -31,9 +31,9 @@ const (
|
|||||||
deprecatedStorageClassAnnotationsMsg = `deprecated since v1.8; use "storageClassName" attribute instead`
|
deprecatedStorageClassAnnotationsMsg = `deprecated since v1.8; use "storageClassName" attribute instead`
|
||||||
)
|
)
|
||||||
|
|
||||||
// DropDisabledFields removes disabled fields from the pv spec.
|
// DropDisabledSpecFields removes disabled fields from the pv spec.
|
||||||
// This should be called from PrepareForCreate/PrepareForUpdate for all resources containing a pv spec.
|
// This should be called from PrepareForCreate/PrepareForUpdate for all resources containing a pv spec.
|
||||||
func DropDisabledFields(pvSpec *api.PersistentVolumeSpec, oldPVSpec *api.PersistentVolumeSpec) {
|
func DropDisabledSpecFields(pvSpec *api.PersistentVolumeSpec, oldPVSpec *api.PersistentVolumeSpec) {
|
||||||
if !utilfeature.DefaultFeatureGate.Enabled(features.CSINodeExpandSecret) && !hasNodeExpansionSecrets(oldPVSpec) {
|
if !utilfeature.DefaultFeatureGate.Enabled(features.CSINodeExpandSecret) && !hasNodeExpansionSecrets(oldPVSpec) {
|
||||||
if pvSpec.CSI != nil {
|
if pvSpec.CSI != nil {
|
||||||
pvSpec.CSI.NodeExpandSecretRef = nil
|
pvSpec.CSI.NodeExpandSecretRef = nil
|
||||||
|
@ -91,7 +91,7 @@ func TestDropDisabledFields(t *testing.T) {
|
|||||||
t.Run(name, func(t *testing.T) {
|
t.Run(name, func(t *testing.T) {
|
||||||
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.CSINodeExpandSecret, tc.csiExpansionEnabled)()
|
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.CSINodeExpandSecret, tc.csiExpansionEnabled)()
|
||||||
|
|
||||||
DropDisabledFields(tc.newSpec, tc.oldSpec)
|
DropDisabledSpecFields(tc.newSpec, tc.oldSpec)
|
||||||
if !reflect.DeepEqual(tc.newSpec, tc.expectNewSpec) {
|
if !reflect.DeepEqual(tc.newSpec, tc.expectNewSpec) {
|
||||||
t.Error(cmp.Diff(tc.newSpec, tc.expectNewSpec))
|
t.Error(cmp.Diff(tc.newSpec, tc.expectNewSpec))
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ func (persistentvolumeStrategy) PrepareForCreate(ctx context.Context, obj runtim
|
|||||||
pv := obj.(*api.PersistentVolume)
|
pv := obj.(*api.PersistentVolume)
|
||||||
pv.Status = api.PersistentVolumeStatus{}
|
pv.Status = api.PersistentVolumeStatus{}
|
||||||
|
|
||||||
pvutil.DropDisabledFields(&pv.Spec, nil)
|
pvutil.DropDisabledSpecFields(&pv.Spec, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (persistentvolumeStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
|
func (persistentvolumeStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
|
||||||
@ -95,7 +95,7 @@ func (persistentvolumeStrategy) PrepareForUpdate(ctx context.Context, obj, old r
|
|||||||
oldPv := old.(*api.PersistentVolume)
|
oldPv := old.(*api.PersistentVolume)
|
||||||
newPv.Status = oldPv.Status
|
newPv.Status = oldPv.Status
|
||||||
|
|
||||||
pvutil.DropDisabledFields(&newPv.Spec, &oldPv.Spec)
|
pvutil.DropDisabledSpecFields(&newPv.Spec, &oldPv.Spec)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (persistentvolumeStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
|
func (persistentvolumeStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
|
||||||
|
Loading…
Reference in New Issue
Block a user