jlandowner / helm-chartsnap

Snapshot testing tool for Helm charts
MIT License
15 stars 3 forks source link

Take an empty snapshot for empty Helm output #97

Closed ktarplee closed 4 months ago

ktarplee commented 4 months ago

My default values for my chart do not produce any manifests. I have templates in there but they are all guarded by if statements.

helm chartsnap -c charts/project -u
 RUNS  Snapshot testing chart=charts/project values=
 FAIL  chart=charts/ace-project values= err=failed to encode manifests: failed to close encoder: yaml: expected STREAM-START
time=2024-04-09T14:12:24.545-04:00 level=ERROR msg="failed to get snapshot chart=charts/project values=: failed to encode manifests: failed to close encoder: yaml: expected STREAM-START"
Error: plugin "chartsnap" exited with error
ktarplee commented 4 months ago

This is using chartsnap chartsnap version version=0.3.1 commit=2c270385287801f32dd088439e348c22e7e7a874 date=2024-04-09T14:45:53Z with helm version version.BuildInfo{Version:"v3.14.3", GitCommit:"f03cc04caaa8f6d7c3e67cf918929150cf6f3f12", GitTreeState:"clean", GoVersion:"go1.22.1"}.

jlandowner commented 4 months ago

@ktarplee Thank you for reporting!

My default values for my chart do not produce any manifests. I have templates in there but they are all guarded by if statements.

It's interesting usecase I didn't come up with😳

A behavior you expected is to take an empty snapshot successfully?

ktarplee commented 4 months ago

The chart I have has lots of files in the templates folder. It is just that when a particular set of values it happens to produce nothing when calling helm template. So the snapshot would be empty.

I think this tool just needs to handle this corner case by allowing an empty list of manifests.

jlandowner commented 4 months ago

We now support an empty snapshot from v0.4.0 🙌