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

fix missing ToFieldPath in conversion #186

Merged
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
2 changes: 2 additions & 0 deletions apis/object/v1alpha1/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

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

Expand Down
4 changes: 4 additions & 0 deletions apis/object/v1alpha1/conversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ func TestConvertTo(t *testing.T) {
},
FieldPath: pointer.String("data.password"),
},
ToFieldPath: pointer.String("data"),
},
},
Readiness: v1alpha1.Readiness{Policy: v1alpha1.ReadinessPolicySuccessfulCreate},
Expand Down Expand Up @@ -133,6 +134,7 @@ func TestConvertTo(t *testing.T) {
},
FieldPath: pointer.String("data.password"),
},
ToFieldPath: pointer.String("data"),
},
},
Readiness: v1alpha2.Readiness{Policy: v1alpha2.ReadinessPolicySuccessfulCreate},
Expand Down Expand Up @@ -333,6 +335,7 @@ func TestConvertFrom(t *testing.T) {
},
FieldPath: pointer.String("data.password"),
},
ToFieldPath: pointer.String("data"),
},
},
Readiness: v1alpha2.Readiness{Policy: v1alpha2.ReadinessPolicySuccessfulCreate},
Expand Down Expand Up @@ -378,6 +381,7 @@ func TestConvertFrom(t *testing.T) {
},
FieldPath: pointer.String("data.password"),
},
ToFieldPath: pointer.String("data"),
},
},
Readiness: v1alpha1.Readiness{Policy: v1alpha1.ReadinessPolicySuccessfulCreate},
Expand Down
33 changes: 33 additions & 0 deletions examples/object/deprecated/patches-from-resource.yaml
Original file line number Diff line number Diff line change
@@ -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
Loading