Skip to content

Add comment support when parsing YAML files #602

Open
@fredgate

Description

@fredgate

I have a Helm chart that I test for Kubernetes API deprecations using deprek8ion policies.

Here is the command and output I have :

helm template my-chart-1.0.0.tgz | conftest test -o json -
[
        {
                "filename": "",
                "namespace": "main",
                "successes": 71,
                "warnings": [
                        {
                                "msg": "Ingress/my-ingress: API networking.k8s.io/v1beta1 for Ingress is deprecated from Kubernetes 1.19, use networking.k8s.io/v1 instead."
                        }
                ]
        }
]

In the result, the filename is missing.

My chart I have one file by resource (one file for deployment, another file for service, yet another file for ingress...), but the helm template command render one output with a multi document YAML like that

...

---
# Source: my-chart/templates/service.yaml
apiVersion: v1
kind: Service
metadata:
  name: my-service
spec:
...

---
# Source: my-chart/templates/ingress.yaml
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: my-ingress
spec:
...

Each resource is prefixed with a comment indicating the file containing the resource definition. But this information is not reported in conftest output.
How to proceed ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions