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

[Bug] Template bindings cannot be changed #2133

Open
1 task done
cbandy opened this issue Nov 6, 2024 · 1 comment
Open
1 task done

[Bug] Template bindings cannot be changed #2133

cbandy opened this issue Nov 6, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@cbandy
Copy link

cbandy commented Nov 6, 2024

chainsaw version Version

v0.2.11

Description

I tried using a step template with bindings but could not change their values using with.bindings.

Steps to reproduce

Create a simple test with one template:

# chainsaw-test.yaml
apiVersion: chainsaw.kyverno.io/v1alpha1
kind: Test
metadata:
  name: template-bindings
spec:
  steps:
  - use:
      template: template.yaml
      with:
        bindings:
        - name: input
          value: from-test # 👈
# template.yaml
apiVersion: chainsaw.kyverno.io/v1alpha1
kind: StepTemplate
metadata:
  name: template
spec:
  bindings:
  - name: input
    value: from-template # 👈

  try:
  - create:
      resource:
        apiVersion: v1
        kind: ConfigMap
        metadata:
          name: ($input)

See that chainsaw test uses the value from-template rather than from-test:

$ chainsaw test
Version: v0.2.11
Loading default configuration...
- Using test file: chainsaw-test
- TestDirs [.]
- SkipDelete false
- FailFast false
- Namespace ''
- FullName false
- IncludeTestRegex ''
- ExcludeTestRegex ''
- ApplyTimeout 5s
- AssertTimeout 30s
- CleanupTimeout 30s
- DeleteTimeout 15s
- ErrorTimeout 30s
- ExecTimeout 5s
- DeletionPropagationPolicy Background
- Template true
- NoCluster false
- PauseOnFailure false
Loading tests...
- template-bindings (.)
Loading values...
Running tests...
=== RUN   chainsaw
=== PAUSE chainsaw
=== CONT  chainsaw
=== RUN   chainsaw/template-bindings
=== PAUSE chainsaw/template-bindings
=== CONT  chainsaw/template-bindings
    | 14:18:05 | template-bindings | @chainsaw | CREATE    | OK    | v1/Namespace @ chainsaw-settled-mosquito
    | 14:18:05 | template-bindings | step-1    | TRY       | BEGIN |
    | 14:18:05 | template-bindings | step-1    | CREATE    | RUN   | v1/ConfigMap @ chainsaw-settled-mosquito/from-template 👈
    | 14:18:05 | template-bindings | step-1    | CREATE    | OK    | v1/ConfigMap @ chainsaw-settled-mosquito/from-template 👈
    | 14:18:05 | template-bindings | step-1    | CREATE    | DONE  | v1/ConfigMap @ chainsaw-settled-mosquito/from-template 👈
    | 14:18:05 | template-bindings | step-1    | TRY       | END   |
    | 14:18:05 | template-bindings | step-1    | CLEANUP   | BEGIN |
    | 14:18:05 | template-bindings | step-1    | DELETE    | OK    | v1/ConfigMap @ chainsaw-settled-mosquito/from-template 👈
    | 14:18:05 | template-bindings | step-1    | CLEANUP   | END   |
    | 14:18:05 | template-bindings | @chainsaw | CLEANUP   | BEGIN |
    | 14:18:05 | template-bindings | @chainsaw | DELETE    | OK    | v1/Namespace @ chainsaw-settled-mosquito
    | 14:18:10 | template-bindings | @chainsaw | CLEANUP   | END   |
--- PASS: chainsaw (0.00s)
    --- PASS: chainsaw/template-bindings (5.28s)
PASS
Tests Summary...
- Passed  tests 1
- Failed  tests 0
- Skipped tests 0
Done.

Expected behavior

I expected the template bindings to be the "default" of sorts. I expected that when the test imports the template, the test gets to decide the values of bindings.

Screenshots

No response

Logs

No response

Slack discussion

No response

Troubleshooting

  • I have searched other issues in this repository and mine is not recorded.
@cbandy cbandy added the bug Something isn't working label Nov 6, 2024
@cbandy
Copy link
Author

cbandy commented Nov 6, 2024

Perhaps these are the lines that affect the template binding precedence:

step.Bindings = append(step.Bindings, step.Use.With.Bindings...)
step.Bindings = append(step.Bindings, template.Spec.Bindings...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant