mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 20:53:33 +00:00
Limit declarative validation to spec until subresource support is added
This commit is contained in:
parent
6ef1a1f98e
commit
5a98d4dbb4
@ -130,7 +130,8 @@ func (rcStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorL
|
|||||||
allErrs := corevalidation.ValidateReplicationController(controller, opts)
|
allErrs := corevalidation.ValidateReplicationController(controller, opts)
|
||||||
|
|
||||||
// If DeclarativeValidation feature gate is enabled, also run declarative validation
|
// If DeclarativeValidation feature gate is enabled, also run declarative validation
|
||||||
if utilfeature.DefaultFeatureGate.Enabled(features.DeclarativeValidation) {
|
// FIXME: isSpecRequest(ctx) limits Declarative validation to the spec until subresource support is introduced.
|
||||||
|
if utilfeature.DefaultFeatureGate.Enabled(features.DeclarativeValidation) && isSpecRequest(ctx) {
|
||||||
// Determine if takeover is enabled
|
// Determine if takeover is enabled
|
||||||
takeover := utilfeature.DefaultFeatureGate.Enabled(features.DeclarativeValidationTakeover)
|
takeover := utilfeature.DefaultFeatureGate.Enabled(features.DeclarativeValidationTakeover)
|
||||||
|
|
||||||
@ -175,7 +176,6 @@ func (rcStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) f
|
|||||||
newRc := obj.(*api.ReplicationController)
|
newRc := obj.(*api.ReplicationController)
|
||||||
|
|
||||||
opts := pod.GetValidationOptionsFromPodTemplate(newRc.Spec.Template, oldRc.Spec.Template)
|
opts := pod.GetValidationOptionsFromPodTemplate(newRc.Spec.Template, oldRc.Spec.Template)
|
||||||
// FIXME: Calling both validator functions here results in redundant calls to ValidateReplicationControllerSpec.
|
|
||||||
// This should be fixed to avoid the redundant calls, but carefully.
|
// This should be fixed to avoid the redundant calls, but carefully.
|
||||||
validationErrorList := corevalidation.ValidateReplicationController(newRc, opts)
|
validationErrorList := corevalidation.ValidateReplicationController(newRc, opts)
|
||||||
updateErrorList := corevalidation.ValidateReplicationControllerUpdate(newRc, oldRc, opts)
|
updateErrorList := corevalidation.ValidateReplicationControllerUpdate(newRc, oldRc, opts)
|
||||||
@ -199,7 +199,8 @@ func (rcStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) f
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If DeclarativeValidation feature gate is enabled, also run declarative validation
|
// If DeclarativeValidation feature gate is enabled, also run declarative validation
|
||||||
if utilfeature.DefaultFeatureGate.Enabled(features.DeclarativeValidation) {
|
// FIXME: This limits Declarative validation to the spec until subresource support is introduced.
|
||||||
|
if utilfeature.DefaultFeatureGate.Enabled(features.DeclarativeValidation) && isSpecRequest(ctx) {
|
||||||
// Determine if takeover is enabled
|
// Determine if takeover is enabled
|
||||||
takeover := utilfeature.DefaultFeatureGate.Enabled(features.DeclarativeValidationTakeover)
|
takeover := utilfeature.DefaultFeatureGate.Enabled(features.DeclarativeValidationTakeover)
|
||||||
|
|
||||||
@ -218,6 +219,13 @@ func (rcStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) f
|
|||||||
return errs
|
return errs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func isSpecRequest(ctx context.Context) bool {
|
||||||
|
if requestInfo, found := genericapirequest.RequestInfoFrom(ctx); found {
|
||||||
|
return len(requestInfo.Subresource) == 0
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
// WarningsOnUpdate returns warnings for the given update.
|
// WarningsOnUpdate returns warnings for the given update.
|
||||||
func (rcStrategy) WarningsOnUpdate(ctx context.Context, obj, old runtime.Object) []string {
|
func (rcStrategy) WarningsOnUpdate(ctx context.Context, obj, old runtime.Object) []string {
|
||||||
var warnings []string
|
var warnings []string
|
||||||
|
Loading…
Reference in New Issue
Block a user