jlandowner/helm-chartsnap

[Feature] Warning message with indentation error

Closed this issue · 3 comments

Hi,
I am writing to request a feature enhancement in your chartsnap plugin. Specifically, I would like the system to generate a warning when the indexing of YAML files is incorrect. For example, this example:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: test
spec:
  replicas: 1
    spec:
      imagePullSecrets:
      - name: {{ .Values.imagePullSecrets }}

Currently, when there is an issue with the indexing of these files, it can lead to unexpected behavior in our application, which is difficult to debug due to the lack of explicit warnings or error messages.

Implementing this feature would greatly improve our ability to identify and resolve issues more efficiently, thereby improving the overall robustness of our application.

I look forward to your positive response. Because this approach, we could resolve a lot of issues in our debugging.

Thank you for all your help.
Best regards,
Sofía

Hi @sofia-fernandez-six. Thank you for opening issue.

If you would like to validate your YAML logically, https://github.com/kubernetes-sigs/kubectl-validate is good choise.

chartsnap can take a snapshot as a standard YAML that helm outputs so you can pass it to kubectl-validate.

I tried it and I can find kubectl-validate actually validate the invalid indentation.
スクリーンショット 2024-05-14 23 19 56

But I also found a pain that kubectl-validate only supports to pass manifests from file that extention must be .yaml or .yml, though chartsnap's snapshot file is .snap.

https://github.com/kubernetes-sigs/kubectl-validate/blob/v0.0.3/pkg/utils/files.go#L9-L12

So currently you have to run kubectl validate with rename the snapshot file.

cp example/app1/test/__snapshots__/test_ingress_enabled.snap test_ingress_enabled.yaml && kubectl validate test_ingress_enabled.yaml

There are some options to resolve it.

  1. Wait for kubectl-validate support to validate from stdin.
    The issue already exists: kubernetes-sigs/kubectl-validate#32

    Then you can run like this

    cat example/app1/test/__snapshots__/test_ingress_enabled.snap | kubectl validate -
  2. Change chartsnap snapshot file extention to .yaml. e.g. test_ingress_enabled.snap.yaml

    Then you can run like this

    kubectl validate example/app1/test/__snapshots__/test_ingress_enabled.snap.yaml

option1 may be available soon as PR seems to be opened recently: kubernetes-sigs/kubectl-validate#125
But option2 makes sense and may be good to support it anyway.

I found certainly Option2 makes sense...🤣
スクリーンショット 2024-05-14 23 45 44

Thank you for the suppot @jlandowner ,
maybe we will try kubectl validate plugin.