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
Note: default disallows user to remove field from object. If user try to remove a field with default from spec, API just adds it back with the default value.
Upgrades would work with these changes. A sample DPA prior to upgrade
// Default BackupImages behavior when nil to true func (dpa*DataProtectionApplication) BackupImages() bool {
returndpa.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.
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: