From 7445b674309a89a41c0e79d72f54bea0538423ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20Schmitz=20von=20H=C3=BClst?= Date: Mon, 22 Jun 2026 01:29:20 +0200 Subject: [PATCH] docs: document fieldpath semantics in Unstructured.SetValue MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Moritz Schmitz von Hülst --- resource/composed/composed.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/resource/composed/composed.go b/resource/composed/composed.go index ec19638..633ee02 100644 --- a/resource/composed/composed.go +++ b/resource/composed/composed.go @@ -256,6 +256,26 @@ func getNumber(p *fieldpath.Paved, path string) (float64, error) { } // SetValue at the supplied field path. +// +// The path uses dot notation to traverse nested fields (e.g., "spec.forProvider.region"). +// Dots in the path are treated as separators, so a path like +// "metadata.labels.prometheus.io.metrics" creates nested maps: +// +// metadata: +// labels: +// prometheus: +// io: +// metrics: +// +// To set label or annotation keys that contain dots (e.g., "prometheus.io/port"), +// use the embedded Unstructured methods instead: +// +// cd.SetLabels(map[string]string{"prometheus.io/port": "9090"}) +// cd.SetAnnotations(map[string]string{"prometheus.io/scrape": "true"}) +// +// These methods preserve the full key name without interpreting dots as separators. +// Note that SetLabels and SetAnnotations replace the entire labels/annotations map; +// use GetLabels/GetAnnotations first if you need to merge with existing values. func (cd *Unstructured) SetValue(path string, value any) error { return fieldpath.Pave(cd.Object).SetValue(path, value) }