mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-02-21 22:57:15 +00:00
chore(validation): add validation identifier for declarative validation in ResourceClaim
This commit is contained in:
@@ -101,8 +101,9 @@ func (s *resourceclaimStrategy) Validate(ctx context.Context, obj runtime.Object
|
||||
|
||||
if utilfeature.DefaultFeatureGate.Enabled(features.DeclarativeValidation) {
|
||||
takeover := utilfeature.DefaultFeatureGate.Enabled(features.DeclarativeValidationTakeover)
|
||||
declarativeErrs := rest.ValidateDeclaratively(ctx, legacyscheme.Scheme, claim, rest.WithTakeover(takeover))
|
||||
rest.CompareDeclarativeErrorsAndEmitMismatches(ctx, allErrs, declarativeErrs, takeover)
|
||||
const validationIdentifier = "resourceclaim_create"
|
||||
declarativeErrs := rest.ValidateDeclaratively(ctx, legacyscheme.Scheme, claim, rest.WithTakeover(takeover), rest.WithValidationIdentifier(validationIdentifier))
|
||||
rest.CompareDeclarativeErrorsAndEmitMismatches(ctx, allErrs, declarativeErrs, takeover, validationIdentifier)
|
||||
if takeover {
|
||||
allErrs = append(allErrs.RemoveCoveredByDeclarative(), declarativeErrs...)
|
||||
}
|
||||
@@ -138,8 +139,9 @@ func (s *resourceclaimStrategy) ValidateUpdate(ctx context.Context, obj, old run
|
||||
|
||||
if utilfeature.DefaultFeatureGate.Enabled(features.DeclarativeValidation) {
|
||||
takeover := utilfeature.DefaultFeatureGate.Enabled(features.DeclarativeValidationTakeover)
|
||||
declarativeErrs := rest.ValidateUpdateDeclaratively(ctx, legacyscheme.Scheme, newClaim, oldClaim, rest.WithTakeover(takeover))
|
||||
rest.CompareDeclarativeErrorsAndEmitMismatches(ctx, errorList, declarativeErrs, takeover)
|
||||
const validationIdentifier = "resourceclaim_update"
|
||||
declarativeErrs := rest.ValidateUpdateDeclaratively(ctx, legacyscheme.Scheme, newClaim, oldClaim, rest.WithTakeover(takeover), rest.WithValidationIdentifier(validationIdentifier))
|
||||
rest.CompareDeclarativeErrorsAndEmitMismatches(ctx, errorList, declarativeErrs, takeover, validationIdentifier)
|
||||
if takeover {
|
||||
errorList = append(errorList.RemoveCoveredByDeclarative(), declarativeErrs...)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user