You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While the crd-generator currently supports annotations such as @Pattern, @Min, @Max, @Required, etc, which helps to enforce constraints on CRD fields, there is no way of specifying default values. I would appreciate built-in support for setting default values when generating the CustomResourceDefinition.
I suggest implementing a mechanism that allows to define such default values for the CRD fields by using annotations, similar to how existing annotations work. For example:
publicclassMyCustomResourceSpec {
// ... Other annotations@Required@DefaultValue("example")
privateStringexampleValue;
}
Corresponding default: example will be generated in the output CRD, such as:
All in all, I'm in favor of adding this functionality.
The challenge here is that the "default value" expressed in the annotation and emitted in the CRD might be different than the default applied after deserialization(due to Jackson configuration etc.).
This behavior might make things confusing, but I don't think we have any way to extract the "default value" ATM (cc. @metacosm ).
Jackson does support a defaultValue argument with JsonProperty as well.
For context, we already moved away from "reusing existing Annotations" as they are not under our control and we don't want to add more semantics to something outside this codebase.
While the crd-generator currently supports annotations such as
@Pattern
,@Min
,@Max
,@Required
, etc, which helps to enforce constraints on CRD fields, there is no way of specifying default values. I would appreciate built-in support for setting default values when generating the CustomResourceDefinition.Reference: https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/#defaulting
I suggest implementing a mechanism that allows to define such default values for the CRD fields by using annotations, similar to how existing annotations work. For example:
Corresponding
default: example
will be generated in the output CRD, such as:The text was updated successfully, but these errors were encountered: