This commit introduces enum-based validation for the `AllocationConfigSource` field.
The following changes are included:
- The `AllocationConfigSource` type is now marked with `+k8s:enum`.
- The `Source` field in `DeviceAllocationConfiguration` is marked as required.
- Generated validation files are updated to enforce the enum constraint.
- A declarative validation test is added for the `AllocationConfigSource` field.
This commit migrates the validation for the DeviceAllocationResult.Config field to declarative validation by adding the +k8s:maxItems=64 annotation.
The change is applied to the following API versions:
- resource/v1
- resource/v1beta1
- resource/v1beta2
This commit migrates the validation for the AllocationResult.Results field to declarative validation by adding the +k8s:maxItems=32 tag.
This aligns with the existing AllocationResultsMaxSize constant and ensures consistency with similar fields like ReservedFor.
This change is applied to the following API versions:
- resource/v1
- resource/v1beta1
- resource/v1beta2
This commit migrates the validation for the ReservedFor field to declarative validation by adding the +k8s:maxItems=256 tag.
This change is applied to the following versions:
- resource/v1
- resource/v1beta1
- resource/v1beta2
This change migrates the validation for unique device request names
for the DeviceClaim.Requests field to a declarative format.
The `+k8s:unique=map` and `+k8s:listMapKey=name` tags have been added
to the `Requests` field within the `DeviceClaim` API type. This ensures
the generated validation code enforces that all entries in the `requests`
slice have a unique `name`.
This commit adds +k8s:maxItems tags to several slice fields within the ResourceClaimSpec across versions v1, v1beta1, and v1beta2.
The following fields under ResourceClaimSpec are now validated for their maximum number of items:
- DeviceRequest.FirstAvailable
- ExactDeviceRequest.Selectors
- DeviceSubRequest.Selectors
- DeviceConstraint.Requests
- DeviceClaimConfiguration.Requests
This commit introduces a validation rule to limit the number of selectors
in a DeviceClass to 32. This is done by adding the `+k8s:maxItems=32`
marker to the DeviceClassSpec and running the code generator.
The following changes are included:
- Updated `staging/src/k8s.io/api/resource/v*/types.go` with the validation marker.
- Regenerated validation code in `pkg/apis/resource/v*/zz_generated.validations.go`.
- Improved error message in `pkg/apis/resource/validation/validation.go`.
- Added tests in `pkg/registry/resource/deviceclass/declarative_validation_test.go`
to cover the new validation.