Process and write the vhost template in two different operations
The following discussion from !17 (closed) should be addressed:
-
@alossent started a discussion: (+1 comment) The one case where we want to return an error is if we could not write the vhost file onto the filesystem, because that is likely to be a transient problem. On the other hand, if the template processing returned an error, then there is no use retrying - it is another case of invalid CR.
Maybe it would be useful to separate the 2 operations: processing the template (an error is treated like an invalid CR), and writing the file (any error should be returned by the reconcile loop so we try again).
if the template processing returned an error, then there is no use retrying
That's assuming the template is already loaded in memory. If there's an error accessing the template, then we return the error so the operation is retried later.
But we only need to load the template once, so it would preferably be done during initialization in
main.go
(andexit(1)
if loading the template from disk failed) instead of every time we create a vhost file.