crossplane-contrib / function-patch-and-transform

A patch & transform composition function
https://crossplane.io
Apache License 2.0
23 stars 24 forks source link

Unknown toFieldPathPolicy error when MergeObjects policy is used #104

Closed driosalido closed 5 months ago

driosalido commented 5 months ago

Hi! I'm trying to use the new MergeObjects policy option and I get the following error. The same composition without the affected patch works well.

crossplane beta render xencryptionkey-function.yaml ../apis/encryptionkey/aws.yaml functions.yaml
crossplane: error: cannot render composite resource: pipeline step "patch-and-transform" returned a fatal result: invalid Function input: resources[0].patches[1].policy.toFieldPathPolicy: Invalid value: "MergeObjects": unknown toFieldPathPolicy

In this composition resource definition

        resources:
          - base:
              apiVersion: kms.aws.upbound.io/v1beta1
              kind: Key
              spec:
                deletionPolicy: Orphan
                forProvider: {}
                providerConfigRef:
                  name: default
            name: key
            patches:
              - patchSetName: common-fields
                type: PatchSet
              - fromFieldPath: metadata.labels
                policy:
                  toFieldPath: MergeObjects
                toFieldPath: metadata.labels
                type: FromCompositeFieldPath

I'm pretty sure that I've followed the documentation but I don't know why my policy.toFieldPath attribute gets translated into toFieldPathPolicy

Any idea why? am I doing something wrong?

driosalido commented 5 months ago

Using

Crossplane version: v1.15.1 function-patch-and-transform: v0.4.0

phisco commented 5 months ago

I think we still have to cut a release with that, v0.4.0 was cut before that patch was merged

driosalido commented 5 months ago

I saw that the functionality was added into the release notes , this is why I tried to use it

| Add support for toFieldPath policies, replacing upstream MergeOptions by @phisco in https://github.com/crossplane-contrib/function-patch-and-transform/pull/91

driosalido commented 5 months ago

I think I know what's happening. Looking at the PR the correct value is MergeObject instead of MergeObjects as indicated in the documentation. Using MergeObject seems to render correctly

driosalido commented 5 months ago

Ok #102 changed the value names from singular to plural, the same PR changed the documentation but the code that implemented the changes described in the documentation have not yet been released... so although currently it works in 0.4.0 it's better to wait until the new binary is released as the correct values will be changed again