Skip to content

Commit

Permalink
Merge pull request #207 from crossplane-contrib/backport-204-to-relea…
Browse files Browse the repository at this point in the history
…se-0.12

[Backport release-0.12] fix missing ToConnectionSecretKey in conversion
  • Loading branch information
lsviben authored Feb 26, 2024
2 parents cc17d12 + cbec0ab commit d2476cf
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 2 deletions.
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

0 comments on commit d2476cf

Please sign in to comment.