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] Warning message with indentation error #113

Closed
sofia-fernandez-six opened this issue May 14, 2024 · 3 comments
Closed

[Feature] Warning message with indentation error #113

sofia-fernandez-six opened this issue May 14, 2024 · 3 comments

Comments

@sofia-fernandez-six
Copy link

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

@jlandowner
Copy link
Owner

jlandowner commented May 14, 2024

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: Validate from stdin 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.

@jlandowner
Copy link
Owner

jlandowner commented May 14, 2024

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

@sofia-fernandez-six
Copy link
Author

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

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

No branches or pull requests

2 participants