-
-
Notifications
You must be signed in to change notification settings - Fork 193
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
Add option to suppress the generation of template if empty #430
Comments
How is "no output" defined? Do you mean exactly zero characters? or is whitespace (maybe a single newline) considered as "no output" too? I don't think we can adopt this as default behaviour, but optional behaviour controlled by an environment variable may be possible. |
or a command line option? Taking a leaf from Helm its zero or just whitespace, I believe.. |
Going to take a stab at implementing this... any suggestion? |
I'm not sure I want to add a flag just yet for this. It seems like it'd be a rarely-used option.
I didn't know Helm had this behaviour - can you point me to where that's documented?
Sure! A cleanup hook may work, but it'd be a little messy - that presumes that an empty file would be created, then deleted later. I would rather the file only be created if there's data to output (maybe a |
The code in helm is https://github.com/helm/helm/blob/master/cmd/helm/template.go#L239-L250 |
Ah. Thanks @ArcticSnowman. Helm's approach is to buffer the data in memory first then write it out if it's got anything. gomplate renders the template directly into the file, streaming rather than buffering it. I prefer the streaming approach. |
This make any change to that stream a careful change to do... |
@ArcticSnowman not sure if you got anywhere with this, but I've had a stab at it - in #439 - what do you think? |
Yeah I did not get to it, real work got in the way... I'll take a look... |
In our use case the datasource has boolean values to control the generation of certain templates.
There should be an option to suppress the creation of an output file if the template generated no output.
The text was updated successfully, but these errors were encountered: