Specify defaults using annotations, use validating functions exposed by apimachinery, etc.#89
Merged
Merged
Conversation
…he type definition. * Defaultling only occurs on fields, thus moved the defaulting annotation to the field definition. * Remove the explicit defaulting in the defaulting webhook. Signed-off-by: Saketh Kalaga <51327242+renormalize@users.noreply.github.com>
….SchedulingPolicyConfig`. * Default the value to `BestEffort` through the annotation, which will include the default value in the CRD for `PodGangSet`. * Remove the explicit defaulting in the defaulting webhook. Signed-off-by: Saketh Kalaga <51327242+renormalize@users.noreply.github.com>
Signed-off-by: Saketh Kalaga <51327242+renormalize@users.noreply.github.com>
unmarshall
approved these changes
Jun 17, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In general, I prefer specifying the defaults in the CRD itself, instead of a defaulting webhook defaulting these values. This PR attempts to fix a few places where this change was trivial.
Move
+kubebuilder:defaultannotation to the field definition from the type definition.Defaultling only occurs on fields, thus moved the defaulting annotation to the field definition.
Remove the explicit defaulting in the defaulting webhook.
Use
+kubebuilderannotation to default the value ofPodGangTemplateSpec.SchedulingPolicyConfig.Default the value to
BestEffortthrough the annotation, which will include the default value in the CRD forPodGangSet.Remove the explicit defaulting in the defaulting webhook.
Use
apivalidation.ValidateImmutableField()where applicable.Change the type of
PodGangTemplateSpec.Cliquesto[]PodCliqueTemplateSpecfrom[]*PodCliqueTemplateSpec.