From 92d04ce39f12bbeedf9a66526ecbdd4139d85cb9 Mon Sep 17 00:00:00 2001 From: ravilr Date: Fri, 23 Feb 2024 16:20:01 -0800 Subject: [PATCH] fix missing ToConnectionSecretKey in conversion Signed-off-by: ravilr (cherry picked from commit 1fe044426d47692c9c44511e0fb81922c14a5387) --- apis/object/v1alpha1/conversion.go | 6 ++-- apis/object/v1alpha1/conversion_test.go | 16 +++++++++ .../object/deprecated/connection-details.yaml | 33 +++++++++++++++++++ 3 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 examples/object/deprecated/connection-details.yaml diff --git a/apis/object/v1alpha1/conversion.go b/apis/object/v1alpha1/conversion.go index a1f5cef9..33f3e401 100644 --- a/apis/object/v1alpha1/conversion.go +++ b/apis/object/v1alpha1/conversion.go @@ -43,7 +43,8 @@ func (src *Object) ConvertTo(dstRaw conversion.Hub) error { // nolint:golint // connectionDetails := []v1alpha2.ConnectionDetail{} for _, cd := range src.Spec.ConnectionDetails { connectionDetails = append(connectionDetails, v1alpha2.ConnectionDetail{ - ObjectReference: cd.ObjectReference, + ObjectReference: cd.ObjectReference, + ToConnectionSecretKey: cd.ToConnectionSecretKey, }) } @@ -123,7 +124,8 @@ func (dst *Object) ConvertFrom(srcRaw conversion.Hub) error { // nolint:golint, connectionDetails := []ConnectionDetail{} for _, cd := range src.Spec.ConnectionDetails { connectionDetails = append(connectionDetails, ConnectionDetail{ - ObjectReference: cd.ObjectReference, + ObjectReference: cd.ObjectReference, + ToConnectionSecretKey: cd.ToConnectionSecretKey, }) } diff --git a/apis/object/v1alpha1/conversion_test.go b/apis/object/v1alpha1/conversion_test.go index 3d46176f..530c5e47 100644 --- a/apis/object/v1alpha1/conversion_test.go +++ b/apis/object/v1alpha1/conversion_test.go @@ -64,7 +64,9 @@ func TestConvertTo(t *testing.T) { APIVersion: "v1", Kind: "Secret", Name: "topsecret", + FieldPath: "data.token", }, + ToConnectionSecretKey: "token", }, }, ForProvider: v1alpha1.ObjectParameters{ @@ -111,7 +113,9 @@ func TestConvertTo(t *testing.T) { APIVersion: "v1", Kind: "Secret", Name: "topsecret", + FieldPath: "data.token", }, + ToConnectionSecretKey: "token", }, }, ForProvider: v1alpha2.ObjectParameters{ @@ -196,7 +200,9 @@ func TestConvertTo(t *testing.T) { APIVersion: "v1", Kind: "Secret", Name: "topsecret", + FieldPath: "data.token", }, + ToConnectionSecretKey: "token", }, }, ForProvider: v1alpha1.ObjectParameters{ @@ -229,7 +235,9 @@ func TestConvertTo(t *testing.T) { APIVersion: "v1", Kind: "Secret", Name: "topsecret", + FieldPath: "data.token", }, + ToConnectionSecretKey: "token", }, }, ForProvider: v1alpha2.ObjectParameters{ @@ -312,7 +320,9 @@ func TestConvertFrom(t *testing.T) { APIVersion: "v1", Kind: "Secret", Name: "topsecret", + FieldPath: "data.token", }, + ToConnectionSecretKey: "token", }, }, ForProvider: v1alpha2.ObjectParameters{ @@ -357,7 +367,9 @@ func TestConvertFrom(t *testing.T) { APIVersion: "v1", Kind: "Secret", Name: "topsecret", + FieldPath: "data.token", }, + ToConnectionSecretKey: "token", }, }, ForProvider: v1alpha1.ObjectParameters{ @@ -407,7 +419,9 @@ func TestConvertFrom(t *testing.T) { APIVersion: "v1", Kind: "Secret", Name: "topsecret", + FieldPath: "data.token", }, + ToConnectionSecretKey: "token", }, }, ForProvider: v1alpha2.ObjectParameters{ @@ -438,7 +452,9 @@ func TestConvertFrom(t *testing.T) { APIVersion: "v1", Kind: "Secret", Name: "topsecret", + FieldPath: "data.token", }, + ToConnectionSecretKey: "token", }, }, ForProvider: v1alpha1.ObjectParameters{ diff --git a/examples/object/deprecated/connection-details.yaml b/examples/object/deprecated/connection-details.yaml new file mode 100644 index 00000000..255d45f0 --- /dev/null +++ b/examples/object/deprecated/connection-details.yaml @@ -0,0 +1,33 @@ +apiVersion: v1 +kind: ServiceAccount +metadata: + namespace: default + name: test-sa +--- +apiVersion: kubernetes.crossplane.io/v1alpha1 +kind: Object +metadata: + name: test-sa +spec: + connectionDetails: + - apiVersion: v1 + fieldPath: data.token + kind: Secret + name: test-sa-token + namespace: default + toConnectionSecretKey: token + forProvider: + manifest: + apiVersion: v1 + kind: Secret + metadata: + annotations: + kubernetes.io/service-account.name: test-sa + name: test-sa-token + namespace: default + type: kubernetes.io/service-account-token + providerConfigRef: + name: kubernetes-provider + writeConnectionSecretToRef: + name: test-sa-conn-out + namespace: default