-
Notifications
You must be signed in to change notification settings - Fork 8
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
Validator integration #44
Comments
One possibility I found so far is to use the $ helm chartsnap -c my-chart/ -u -- --output-dir ./foo/test
RUNS Snapshot testing chart=my-chart/ values=
time=2023-12-23T13:44:58.450+01:00 level=INFO msg="loading helm output is done with warning"
WARN: failed to recognize a resource. snapshot as Unknown:
---
object:
apiVersion: helm-chartsnap.jlandowner.dev/v1alpha1
kind: Unknown
raw: |+
wrote ./foo/my-chart/templates/cronjob.yaml
---
FAIL Snapshot does not match chart=my-chart/ values=
Expected to match
--- kind= name= line=1
- object:
- apiVersion: batch/v1
- kind: CronJob
- metadata:
...
+ apiVersion: helm-chartsnap.jlandowner.dev/v1alpha1
+ kind: Unknown
+ raw: |+
+ wrote ./foo/my-chart/templates/cronjob.yaml
+ |
Hi @florianrusch, Thank you for raising! Could you provide more details about the integration of a varidator tool?
Basically, all that is needed for Helm is the chart and values. Therefore, for integration testing, I thought you can use the test values files to e.g. So it was not intended for the snapshot files to integrate with other tools for now. Also some implementation reasons led to the current snapshot file format.
I'm open to supporting a better format and appriciate the suggestion 🙌 |
Hi, thanks for your reply! I don't have a specific tool in mind, but for example kubectl validate would require the yaml resources to validate against the official schema: https://github.com/kubernetes-sigs/kubectl-validate/#usage There are also a lot of other tools that would require yaml resources. You can find a good list here: https://github.com/HighwayofLife/kubernetes-validation-tools So the idea would be to use helm-chartsnap to generate the resources in yaml format and do a first validation (snapshot test). Then we could reuse the yaml output as input for the other tools. |
Thank you for more information! As I mentioned above, chartsnap captures stdout and stderr and unknown output as I will look into them and try to find how chartsnap can be integrated with them(including using test values files, not snapshot file) |
@jlandowner thanks for your reply! I'm looking at this right now too. Basically, the bottom change would be to swap out the toml en/decoder with a yaml en/decoder. But I still have the following in every snapshot file: default:
snapshot: |
- object:
apiVersion: batch/v1
kind: CronJob
metadata:
...
- object:
apiVersion: ... What I try to archive would be something like this: apiVersion: batch/v1
kind: CronJob
metadata:
...
---
apiVersion: ...
EDIT: I have already solved the puzzle myself. It's needed for the tests, isn't it? Are there any other use cases apart from the tests? |
@florianrusch Thanks for looking into my codes. The codes about snapshot files ( But for chartsnap, a single snapshot(=a test values file, set of output of helm template) is stored in a single snapshot file so it does not so matter. It's just the name of a test values file( |
Supported output as YAML in #85 😊 |
Personally, I like the '.snap' file extensions. It makes clear, that these files are not normal k8s resource yaml files and that they contain snapshots. Maybe we can think of adding an additional suffix like WDYT? |
I agree. Actually I am using |
@jlandowner is this still a todo? |
Absolutely, but I couldn't work on it these days😓 |
@jlandowner thanks for this amazing tool!
I was looking for exactly something like this, because I work in a project with multiple different developers, which all have different levels of experiences with helm and how to write and modify helm charts.
I'm just wondering, if it's somehow possible to also integrate a validator tool to validate the generated yaml code against the kubernetes api. Did you or someone else already thought about something like that? It would be really easy, if the snapshots would be stored as plain yaml files.
The text was updated successfully, but these errors were encountered: