Skip to content

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

@nicolascollet-aldebarancom

Description

chainsaw version Version

v0.2.12

Description

see: #1275 (comment)

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

  • 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