diff options
| author | Dave Henderson <dhenderson@gmail.com> | 2019-03-31 15:31:33 -0400 |
|---|---|---|
| committer | Dave Henderson <dhenderson@gmail.com> | 2019-03-31 15:45:12 -0400 |
| commit | a602ee3ec7c42ce53057e26fefdf8a949a10eb7b (patch) | |
| tree | bef57b8f24931f507191c78578f90d403c13f820 /template.go | |
| parent | 197ad689bc2922012e4573386214d3a844ca827e (diff) | |
Refactor Config
Signed-off-by: Dave Henderson <dhenderson@gmail.com>
Diffstat (limited to 'template.go')
| -rw-r--r-- | template.go | 11 |
1 files changed, 3 insertions, 8 deletions
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: "<arg>", 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) |
