kreuzwerker / envplate

Docker-friendly trivial templating for configuration files using environment keys
MIT License
331 stars 44 forks source link

Do not modify files if parsing fails #53

Closed neuroid closed 7 months ago

neuroid commented 8 months ago

What does this do / why do we need it?

Consider the following example:

$ cat file
${UNDECLARED}
$ ep file
2024/03/05 21:33:31 [ ERROR ] 'file' requires undeclared environment variable 'UNDECLARED', no default is given
2024/03/05 21:33:31 [ ERROR ] Error while parsing 'file': 'file' requires undeclared environment variable 'UNDECLARED', no default is give
$ echo $?
1
$ cat file

$

I would expect the file to not be modified since the command resulted in an error.

How this PR fixes the problem?

The proposed change aborts writing the modified buffer if any errors occurred.

What should your reviewer look out for in this PR?

N/A

Check lists

Additional Comments (if any)

N/A

Which issue(s) does this PR fix?

N/A

neuroid commented 8 months ago

Hi @mavogel 👋 Is this something you would be interested in merging?

enc commented 8 months ago

I will have a look into the pipeline later. Thank you for reminding us.