Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The main contribution here is in the last commit: Instead of producing invalid template content and an error that is very misleading (see also #1), it now produces a warning about the problem and skips the variable. The idea here is that not every variable in the environment might be used in the template, and the warning should be visible enough so that whoever is running caddy can fix it if needed.
The second important part 4cae952, which works around problems when environment variables contain
\
characters: A simplestrconv.Unquote
leaves these, and putting the value into quotes then produces problems when processing the template. Solution is to let Sprintf's%q
format handle the value and quote it properly.The other commits are cleanups and drive-by improvements.