chainsaw icon indicating copy to clipboard operation
chainsaw copied to clipboard

[Bug] YAML anchors are not being rendered when using '<<:'

Open nicolascollet-aldebarancom opened this issue 9 months ago • 1 comments

chainsaw version Version

v0.2.12

Description

see: https://github.com/kyverno/chainsaw/issues/1275#issuecomment-2623557693

the bug still seems to be present in version 0.2.12.

Steps to reproduce

create test with Yaml anchors ...

cd ~ && mkdir -p .chainsaw-test
cat << EOF > .chainsaw-test/chainsaw-test.yaml
apiVersion: chainsaw.kyverno.io/v1alpha1
kind: Test
metadata:
  name: &name yaml-anchors
spec:
  namespace: &namespace default
  steps:
  - name: *name
    try:
    - apply:
        resource: &resource
          apiVersion: v1
          kind: Pod
          metadata:
            name: *name
            namespace: *namespace
          spec:
            containers:
            - name: main
              image: alpine
    - assert:
        resource:
          <<: *resource
          spec:
            restartPolicy: Always
        timeout: 1s
EOF

start test

chainsaw test --namespace chainsaw   
Version: 0.2.12
Loading default configuration...
- Using test file: chainsaw-test
- TestDirs [.]
- SkipDelete false
- FailFast false
- Namespace 'chainsaw'
- 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...
Error: failed to parse document (yaml: unmarshal errors:
  line 26: key "spec" already set in map)

version

chainsaw version                  
Version: 0.2.12
Time: 2024-12-04T13:06:58Z
Git commit ID: 6459cd84a78f13d842e0ff0ad2f6a76c321fd579

Expected behavior

chainsaw test --namespace chainsaw
Version: 0.2.12
Loading default configuration...
- Using test file: chainsaw-test
- TestDirs [.]
- SkipDelete false
- FailFast false
- Namespace 'chainsaw'
- 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...
Running tests...
=== RUN   chainsaw

Screenshots

No response

Logs


Slack discussion

No response

Troubleshooting

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

Hey @nicolascollet-aldebarancom , you can use --remarshal flag to parse your input manifest. What you are looking for by-default, it has been provided by a flag. May be because of performence overhead.

Rohanraj123 avatar Apr 02 '25 07:04 Rohanraj123