crossplane-runtime icon indicating copy to clipboard operation
crossplane-runtime copied to clipboard

Setting a field of Paved object to nil should remove that field

Open muvaf opened this issue 5 years ago • 1 comments

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.

muvaf avatar Aug 20 '20 13:08 muvaf

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.

stale[bot] avatar Aug 13 '22 07:08 stale[bot]

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.

github-actions[bot] avatar Sep 05 '24 01:09 github-actions[bot]