Skip to content

[Bug] Bindings do not work for apply resource metadata labels #2386

@pgmgb

Description

@pgmgb

chainsaw version Version

v0.2.12

Description

We would like to use binding inside the Apply operations under the FileRefOrResource for labels.

Steps to reproduce

---
apiVersion: chainsaw.kyverno.io/v1alpha1
kind: Test
metadata:
  name: my-test
spec:
  steps:
    - name: Create pod with labels
      bindings:
        - name: podName
          value: pod-name
        - name: labelName
          value: my-label
        - name: labelValue
          value: "false"
      try:
        - apply:
            template: true
            resource:
              apiVersion: v1
              kind: Pod
              metadata:
                name: ($podName)
                labels:
                  ($labelName): ($labelValue)

Will result in:

=== ERROR
        Pod "pod-name" is invalid: metadata.labels: Invalid value: "($labelName)": name part must consist of alphanumeric characters, '-', '_' or '.', and must start and end with an alphanumeric character (e.g. 'MyName',  or 'my.name',  or '123-abc', regex used for validation is '([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9]')

Expected behavior

Bindings can be used anywhere inside the FileRefOrResource.

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

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions