You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am new to crossplane and usage of functions so looking for some guidance here. Thank you in advance!
In our composition, we have a resource created in the first pipeline step using go-templating. The resource has spec.forProvider.items field which expects an array input. When the resource is first created in the go-templating step there exists one item in the array (lets call it item-1). There after, we have a 2nd step in the pipeline which implements function P&T to append spec.forProvider.items field/array with one more item listed in the XR/Claim (lets call it item-2).
Snapshot of the expected output in the resource: spec: forProvider: items: - item-1 - item-2
Output/Errors encountered:
Without the transforms applied to the patch we see the error cannot apply composed resource "resource-1": failed to create typed patch object: .spec.forProvider.items: expected list, got &{item-2}
With the transforms applied we see the error cannot compose resources: pipeline step returned a fatal result: cannot render composed resource "resource-1" "CombineFromComposite" patch at index 0 : transform at index 1 returned error: convert transform could not resolve: json: cannot unmarshal string into Go value of type []interface {}
When trying to look around the repo I noticed patches_test.go doesn't test this case. Just one test case to test de-duplication.
When testing this with crossplane beta render we noticed when the transforms are not applied the output is generated but with the default Replace policy applied to the patch (output is items: item-2) instead of the output items: [item-1, item-2].
The text was updated successfully, but these errors were encountered:
annapurnachunduri
changed the title
Issues appending to an Array with policy
Issues appending to an Array with a policy
Jun 7, 2024
annapurnachunduri
changed the title
Issues appending to an Array with a policy
Issues appending to an array with patch policy
Jun 7, 2024
Hi all,
I am new to crossplane and usage of functions so looking for some guidance here. Thank you in advance!
In our composition, we have a resource created in the first pipeline step using go-templating. The resource has
spec.forProvider.items
field which expects an array input. When the resource is first created in the go-templating step there exists one item in the array (lets call ititem-1
). There after, we have a 2nd step in the pipeline which implements function P&T to appendspec.forProvider.items
field/array with one more item listed in the XR/Claim (lets call ititem-2
).Here is the code for the function P&T step:
step: policy patch
functionRef:
name: function-patch-and-transform
input:
apiVersion: pt.fn.crossplane.io/v1beta1
kind: Resources
resources:
- name: resource-1
patches:
- type: CombineFromComposite
toFieldPath: spec.forProvider.items
combine:
variables:
- fromFieldPath: spec.parameters.newItem
strategy: string
string:
fmt: "%s-2"
transforms:
- type: string
string:
type: Convert
convert: "ToJson"
- type: convert
convert:
toType: array
format: json
policy:
toFieldPath: ForceMergeObjectsAppendArrays
Snapshot of the expected output in the resource:
spec:
forProvider:
items:
- item-1
- item-2
Output/Errors encountered:
cannot apply composed resource "resource-1": failed to create typed patch object: .spec.forProvider.items: expected list, got &{item-2}
cannot compose resources: pipeline step returned a fatal result: cannot render composed resource "resource-1" "CombineFromComposite" patch at index 0 : transform at index 1 returned error: convert transform could not resolve: json: cannot unmarshal string into Go value of type []interface {}
patches_test.go
doesn't test this case. Just one test case to test de-duplication.Replace
policy applied to the patch (output isitems: item-2
) instead of the outputitems: [item-1, item-2]
.The text was updated successfully, but these errors were encountered: