-
Notifications
You must be signed in to change notification settings - Fork 1
Description
Describe the bug
The bug reported here happens for objects
- which are not recognized by the effective target schema (typically CRDs) and
- for which the active generator renders invalid labels or annotations, in the sense that the values are not string values (typical scenario: forgotten quotes around booleans or numerics).
These label/annotation key/value pairs are just swallowed. That is, the object is applied without any error to Kubernetes, without the erroneous label/annotation (obviously), and no error is thrown.
Tested with Version
v0.3.134
To Reproduce
Create a component containing a dependent object which is an instance of a CRD. Having a label with a non-string value. Observe that the component is applied without complaints, without the label (of course).
Expected behavior
An error should be raised during rendering.
Additional context
This seems to happen because objects not recognized by the target schema are processed through the unstructured client. If, for such an object,
func (u *Unstructured) GetLabels() map[string]string
or
func (u *Unstructured) GetAnnotations() map[string]string
is called, things start to go wrong. Because these two methods (only these?) involve the functionNestedNullCoercingStringMap() (https://pkg.go.dev/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured#NestedNullCoercingStringMap), but ignore any errors returned by this function:
func (u *Unstructured) GetLabels() map[string]string {
m, _, _ := NestedNullCoercingStringMap(u.Object, "metadata", "labels")
return m
}
(such as type mismatch caused errors).