crossplane-runtime
crossplane-runtime copied to clipboard
Setting a field of Paved object to nil should remove that field
What problem are you facing?
Currently, it's possible to set nil for a field in fieldpath library but that still leaves the map with that key whose value is nil. Later on, when this map is sent to api-server, it doesn't pass the validation since it should've been omitted if it was nil.
How could Crossplane help solve your problem?
Here is code snippet from unstructured.Unstructured:
func (u *Unstructured) SetLabels(labels map[string]string) {
if labels == nil {
RemoveNestedField(u.Object, "metadata", "labels")
return
}
u.setNestedMap(labels, "metadata", "labels")
}
As you can see, in case of nil value, they remove the field completely instead of setting a nil value. I'd suggest we do the same thing in SetValue function in fieldpath.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Crossplane does not currently have enough maintainers to address every issue and pull request. This issue has been automatically marked as stale because it has had no activity in the last 90 days. It will be closed in 14 days if no further activity occurs. Leaving a comment starting with /fresh will mark this issue as not stale.