Skip to content

[Bug] Unable to use binding for kind in patch operation #2499

@ctschacher

Description

@ctschacher

chainsaw version Version

v0.2.13

Description

It seems that it's not possible to replace the kind value in a patch operation with a value from a binding which looks like a bug to me.

The following example of a test step is working fine:

    - name: Update to state STARTED
      try:
        - patch:
            resource:
              apiVersion: test/v1alpha1
              kind: custom-kind
              metadata:
                name: ($apiName)
              spec:
                state: "STARTED"
        - assert:
            resource:
              apiVersion: test/v1alpha1
              kind: custom-kind
              metadata:
                name: ($apiName)
              status:
                state: STARTED
                processingStatus: Completed

Notice that name: ($apiName) doesn't cause any trouble however this example with kind: ($apiKind) is not working:

    - name: Update to state STARTED
      try:
        - patch:
            resource:
              apiVersion: test/v1alpha1
              kind: ($apiKind)
              metadata:
                name: ($apiName)
              spec:
                state: "STARTED"
        - assert:
            resource:
              apiVersion: test/v1alpha1
              kind: ($apiKind)
              metadata:
                name: ($apiName)
              status:
                state: STARTED
                processingStatus: Completed

The test run fails before any steps is executed. Error message:

Loading tests...
Error: failed to validate resource (Test.chainsaw.kyverno.io "export-import" is invalid: spec.steps[4].try[0].patch.resource.kind: Invalid value: "($apiKind)": may have mixed case, but should otherwise match: a DNS-1035 label must consist of lower case alphanumeric characters or '-', start with an alphabetic character, and end with an alphanumeric character (e.g. 'my-name',  or 'abc-123', regex used for validation is '[a-z]([-a-z0-9]*[a-z0-9])?'))

BTW: In my case the binding was defined inside a scenarios bindings.

Steps to reproduce

Expected behavior

I would expect that I can use bindings for the kind value.

Screenshots

No response

Logs

Slack discussion

No response

Troubleshooting

  • I have searched other issues in this repository and mine is not recorded.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ContribfestGood first issues for KubeCon EU 2024bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions