Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport release-0.12] fix missing ToConnectionSecretKey in conversion #207

Merged
merged 1 commit into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions apis/object/v1alpha1/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})
}

Expand Down Expand Up @@ -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,
})
}

Expand Down
16 changes: 16 additions & 0 deletions apis/object/v1alpha1/conversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ func TestConvertTo(t *testing.T) {
APIVersion: "v1",
Kind: "Secret",
Name: "topsecret",
FieldPath: "data.token",
},
ToConnectionSecretKey: "token",
},
},
ForProvider: v1alpha1.ObjectParameters{
Expand Down Expand Up @@ -111,7 +113,9 @@ func TestConvertTo(t *testing.T) {
APIVersion: "v1",
Kind: "Secret",
Name: "topsecret",
FieldPath: "data.token",
},
ToConnectionSecretKey: "token",
},
},
ForProvider: v1alpha2.ObjectParameters{
Expand Down Expand Up @@ -196,7 +200,9 @@ func TestConvertTo(t *testing.T) {
APIVersion: "v1",
Kind: "Secret",
Name: "topsecret",
FieldPath: "data.token",
},
ToConnectionSecretKey: "token",
},
},
ForProvider: v1alpha1.ObjectParameters{
Expand Down Expand Up @@ -229,7 +235,9 @@ func TestConvertTo(t *testing.T) {
APIVersion: "v1",
Kind: "Secret",
Name: "topsecret",
FieldPath: "data.token",
},
ToConnectionSecretKey: "token",
},
},
ForProvider: v1alpha2.ObjectParameters{
Expand Down Expand Up @@ -312,7 +320,9 @@ func TestConvertFrom(t *testing.T) {
APIVersion: "v1",
Kind: "Secret",
Name: "topsecret",
FieldPath: "data.token",
},
ToConnectionSecretKey: "token",
},
},
ForProvider: v1alpha2.ObjectParameters{
Expand Down Expand Up @@ -357,7 +367,9 @@ func TestConvertFrom(t *testing.T) {
APIVersion: "v1",
Kind: "Secret",
Name: "topsecret",
FieldPath: "data.token",
},
ToConnectionSecretKey: "token",
},
},
ForProvider: v1alpha1.ObjectParameters{
Expand Down Expand Up @@ -407,7 +419,9 @@ func TestConvertFrom(t *testing.T) {
APIVersion: "v1",
Kind: "Secret",
Name: "topsecret",
FieldPath: "data.token",
},
ToConnectionSecretKey: "token",
},
},
ForProvider: v1alpha2.ObjectParameters{
Expand Down Expand Up @@ -438,7 +452,9 @@ func TestConvertFrom(t *testing.T) {
APIVersion: "v1",
Kind: "Secret",
Name: "topsecret",
FieldPath: "data.token",
},
ToConnectionSecretKey: "token",
},
},
ForProvider: v1alpha1.ObjectParameters{
Expand Down
33 changes: 33 additions & 0 deletions examples/object/deprecated/connection-details.yaml
Original file line number Diff line number Diff line change
@@ -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
Loading