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

[Feature] Allow overriding yaml files used in the apply operation of a test step #1262

Open
2 tasks done
lantingchiang opened this issue May 8, 2024 · 3 comments
Open
2 tasks done
Labels
enhancement New feature or request

Comments

@lantingchiang
Copy link

Problem Statement

If I have a test like the following:

apiVersion: chainsaw.kyverno.io/v1alpha1
kind: Test
metadata:
  name: test-basic-resource-creation-succeeds
spec:
  steps:
    - name: basic-pod-creation-should-succeed
      try:
        - apply:
            file: ../resources-always-pass/pods.yaml
        - assert:
            resource:
              apiVersion: v1
              kind: Pod
              metadata:
                name: basic-pod

where pods.yaml contains a pod manifest with metatdata.namespace specified. I would like to remove the namespace field or override it so that it gets created in the ephemeral namespace that chainsaw creates. The reason why I'm not directly removing metadata.namespace from pods.yaml is because the same manifest is used for other things.

Solution Description

There should be options to override fields from yaml files that are referenced in the apply operation. For example, I should be able to specify

apiVersion: chainsaw.kyverno.io/v1alpha1
kind: Test
metadata:
  name: test-basic-resource-creation-succeeds
spec:
  steps:
    - name: basic-pod-creation-should-succeed
      try:
        - apply:
            file: ../resources-always-pass/pods.yaml
            overrides:
              path: metadata.namespace
              value: ($namespace)
        - assert:
            resource:
              apiVersion: v1
              kind: Pod
              metadata:
                name: basic-pod

to override the key, or

apiVersion: chainsaw.kyverno.io/v1alpha1
kind: Test
metadata:
  name: test-basic-resource-creation-succeeds
spec:
  steps:
    - name: basic-pod-creation-should-succeed
      try:
        - apply:
            file: ../resources-always-pass/pods.yaml
            overrides:
              path: metadata.namespace
              value: null
        - assert:
            resource:
              apiVersion: v1
              kind: Pod
              metadata:
                name: basic-pod

to remove the key

Alternatives

No response

Additional Context

No response

Slack discussion

https://kubernetes.slack.com/archives/C067LUFL43U/p1715011398814629

Research

  • I have read and followed the documentation AND the troubleshooting guide.
  • I have searched other issues in this repository and mine is not recorded.
@lantingchiang lantingchiang added the enhancement New feature or request label May 8, 2024
Copy link

welcome bot commented May 8, 2024

Thanks for opening your first issue here! Be sure to follow the issue template!

@chipzoller chipzoller transferred this issue from kyverno/kyverno May 8, 2024
@chipzoller
Copy link
Contributor

Transferred to Chainsaw, not a Kyverno core issue.

@eddycharly
Copy link
Member

Thanks for reporting, we could do something specific to override the namespace but a generic solution would be better 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants