From 15a119979d3a8ff6b00b3f24526d57b01d442d2c Mon Sep 17 00:00:00 2001 From: lsviben Date: Mon, 29 Jan 2024 09:51:02 +0100 Subject: [PATCH 1/2] fix missing ToFieldPath in conversion Signed-off-by: lsviben --- apis/object/v1alpha1/conversion.go | 2 ++ apis/object/v1alpha1/conversion_test.go | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/apis/object/v1alpha1/conversion.go b/apis/object/v1alpha1/conversion.go index 0e423fb1..a1f5cef9 100644 --- a/apis/object/v1alpha1/conversion.go +++ b/apis/object/v1alpha1/conversion.go @@ -69,6 +69,7 @@ func (src *Object) ConvertTo(dstRaw conversion.Hub) error { // nolint:golint // FieldPath: r.PatchesFrom.FieldPath, } } + ref.ToFieldPath = r.ToFieldPath references = append(references, ref) } @@ -148,6 +149,7 @@ func (dst *Object) ConvertFrom(srcRaw conversion.Hub) error { // nolint:golint, FieldPath: r.PatchesFrom.FieldPath, } } + ref.ToFieldPath = r.ToFieldPath references = append(references, ref) } diff --git a/apis/object/v1alpha1/conversion_test.go b/apis/object/v1alpha1/conversion_test.go index 41dca560..3d46176f 100644 --- a/apis/object/v1alpha1/conversion_test.go +++ b/apis/object/v1alpha1/conversion_test.go @@ -88,6 +88,7 @@ func TestConvertTo(t *testing.T) { }, FieldPath: pointer.String("data.password"), }, + ToFieldPath: pointer.String("data"), }, }, Readiness: v1alpha1.Readiness{Policy: v1alpha1.ReadinessPolicySuccessfulCreate}, @@ -133,6 +134,7 @@ func TestConvertTo(t *testing.T) { }, FieldPath: pointer.String("data.password"), }, + ToFieldPath: pointer.String("data"), }, }, Readiness: v1alpha2.Readiness{Policy: v1alpha2.ReadinessPolicySuccessfulCreate}, @@ -333,6 +335,7 @@ func TestConvertFrom(t *testing.T) { }, FieldPath: pointer.String("data.password"), }, + ToFieldPath: pointer.String("data"), }, }, Readiness: v1alpha2.Readiness{Policy: v1alpha2.ReadinessPolicySuccessfulCreate}, @@ -378,6 +381,7 @@ func TestConvertFrom(t *testing.T) { }, FieldPath: pointer.String("data.password"), }, + ToFieldPath: pointer.String("data"), }, }, Readiness: v1alpha1.Readiness{Policy: v1alpha1.ReadinessPolicySuccessfulCreate}, From e591f32d6b908e3df5bf5388def5a4abb2348b69 Mon Sep 17 00:00:00 2001 From: lsviben Date: Mon, 29 Jan 2024 10:17:22 +0100 Subject: [PATCH 2/2] add migration example for toFieldPath Signed-off-by: lsviben --- .../deprecated/patches-from-resource.yaml | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 examples/object/deprecated/patches-from-resource.yaml diff --git a/examples/object/deprecated/patches-from-resource.yaml b/examples/object/deprecated/patches-from-resource.yaml new file mode 100644 index 00000000..c2821c6c --- /dev/null +++ b/examples/object/deprecated/patches-from-resource.yaml @@ -0,0 +1,33 @@ +--- +apiVersion: kubernetes.crossplane.io/v1alpha1 +kind: Object +metadata: + name: foo +spec: + references: + # Use patchesFrom to patch field from other k8s resource to this object + - patchesFrom: + apiVersion: v1 + kind: ConfigMap + name: bar + namespace: default + fieldPath: data.sample-key + toFieldPath: data.sample-key-from-bar + forProvider: + manifest: + apiVersion: v1 + kind: ConfigMap + metadata: + namespace: default + data: + sample-key: sample-value + providerConfigRef: + name: kubernetes-provider +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: bar + namespace: default +data: + sample-key: sample-value