-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use CRD defaults #1557
Comments
// Default BackupImages behavior when nil to true
func (dpa *DataProtectionApplication) BackupImages() bool {
return dpa.Spec.BackupImages == nil || *dpa.Spec.BackupImages
} These were added because at the time we want to add configurability while hiding that these are defaulted to true since all users essentially had this on but we want to give the option to turn it off. We didn't want to require DPA update to restore prior behavior. If we had used CRD marker defaults, it would've added a new line to everyone's dpa, which while clearer was seen as "changing user's dpa", an undesired behavior. |
Essentially, What You There are enough examples of controllers / CRDs displaying defaults to users' created CR, so the prior behavior was not a hard requirement. |
Issues go stale after 90d of inactivity. Mark the issue as fresh by commenting If this issue is safe to close now please do so with /lifecycle stale |
/lifecycle frozen |
Problem
OADP does not use default value markers for generating its CRDs
// +kubebuilder:default=<value>
The adoption of this would be better for:
developers
Less code to write. Functions like this would not be necessary, as API would ensure a value is present on the field
oadp-operator/api/v1alpha1/oadp_types.go
Lines 614 to 617 in fb2411e
users
Default values would be more visible to users. Easier to see when default values are updated
Examples
If user creates a DPA with this spec
it would have this spec in the cluster
Upgrades would work with these changes. A sample DPA prior to upgrade
The same DPA after upgarde
References
https://book.kubebuilder.io/reference/markers/crd-validation
https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#defaulting
The text was updated successfully, but these errors were encountered: