From a602ee3ec7c42ce53057e26fefdf8a949a10eb7b Mon Sep 17 00:00:00 2001 From: Dave Henderson Date: Sun, 31 Mar 2019 15:31:33 -0400 Subject: Refactor Config Signed-off-by: Dave Henderson --- template.go | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'template.go') diff --git a/template.go b/template.go index 5a723ab6..7697cef2 100644 --- a/template.go +++ b/template.go @@ -97,6 +97,7 @@ func (t *tplate) addTarget() (err error) { // gatherTemplates - gather and prepare input template(s) and output file(s) for rendering // nolint: gocyclo func gatherTemplates(o *Config) (templates []*tplate, err error) { + o.defaults() mode, modeOverride, err := o.getMode() if err != nil { return nil, err @@ -104,19 +105,13 @@ func gatherTemplates(o *Config) (templates []*tplate, err error) { // the arg-provided input string gets a special name if o.Input != "" { - if mode == 0 { - mode = 0644 - } templates = []*tplate{{ name: "", contents: o.Input, mode: mode, modeOverride: modeOverride, + targetPath: o.OutputFiles[0], }} - - if len(o.OutputFiles) == 1 { - templates[0].targetPath = o.OutputFiles[0] - } } // input dirs presume output dirs are set too @@ -125,7 +120,7 @@ func gatherTemplates(o *Config) (templates []*tplate, err error) { if err != nil { return nil, err } - } else if len(o.InputFiles) > 0 && o.Input == "" { + } else if o.Input == "" { templates = make([]*tplate, len(o.InputFiles)) for i := range o.InputFiles { templates[i], err = fileToTemplates(o.InputFiles[i], o.OutputFiles[i], mode, modeOverride) -- cgit v1.2.3