- Rename type params to Tstruct/Tfield/Tdisc for Subfield consistency
- Make DiscriminatedRule.Value generic over Tdisc and emit typed literals
- Move discriminator assignment adjacent to value assignment
- Fix mockEqual to test value equivalence and add pointer test
- Add test for value changed with discriminator unchanged
- Add regex validation for discriminator group names
- Disallow "default" as an explicit discriminator group name
- Add directComparable cross-reference comment for ratcheting
- Rename mode/modal terminology to discriminator/member
This introduces state-based validation to declarative validation via the +k8s:discriminator and +k8s:member tags.
Key changes:
- Added validate.Modal runtime function to handle state-based logic, including full ratcheting support (skipping validation on Update if discriminator and value are unchanged).
- Implemented +k8s:discriminator to identify the controlling field (supports string, int, and bool).
- Implemented +k8s:member to map discriminator values to validation rules.
- Added implicit "forbidden-by-default" logic for unhandled modes, with support for pointer, slice, and map types.
This introduces MultiWrapperFunction to the generator AST, allowing multiple validation functions to be bundled into a single emitted closure. It correctly handles short-circuiting logic for the wrapped functions.
Introduce IsAlpha() and IsBeta() helper methods on field.Error to
encapsulate stability level checks. Unexport the underlying
ValidationStabilityLevel constants to keep the API surface minimal.
Update the apiserver's validation logic to use these helpers.
- Update resttest and genericregistrytest to support RequestInfo injection.
- Inject RequestInfo in Workload storage and strategy tests to resolve context-related failures.
- Refine validate.go log messages and error deduplication logic.
- Test scenarios: Beta Enabled, Beta Disabled, and Legacy (emulated 1.35).
- Remove deprecated Takeover gate references and redundant coverage checks.
- Add TODO to remove legacy emulation in 1.39.
- Update documentation to match the new Validation Lifecycle strategy.
Mark Workload v1alpha1 validations as +k8s:alpha(since:"1.35") and
configure the registry strategy to use WithDeclarativeEnforcement().
This transitions the resource to the stability-based validation lifecycle,
where enforcement is determined by tag stability and feature gates.
Includes generated code updates.
- Introduce WithDeclarativeEnforcement to opt-in to the lifecycle model.
- Update ValidateDeclarativelyWithMigrationChecks to:
- Enforce Beta-level validations when DeclarativeValidationBeta is enabled.
- Shadow Alpha-level validations.
- Filter handwritten errors only for Beta-level validations (when enabled).
- Limit mismatch checking to Alpha and Beta stages when enforcement is enabled.
- Deprecate WithDeclarativeNative and DeclarativeNative field in field.Error.
- Add comprehensive lifecycle tests and clean up redundant test cases.
This change introduces the DeclarativeValidationBeta feature gate in v1.36
as the global safety switch for Beta-stage validation rules and marks
DeclarativeValidationTakeover as deprecated.
Following KEP-5073.