From aedc3c841feab0b679327074f5fdb5b63061f58b Mon Sep 17 00:00:00 2001 From: ben dewan Date: Mon, 23 Apr 2018 13:19:38 -0400 Subject: [PATCH] Writing output files from a stdin template requires permissions This fixes #304 --- template.go | 1 + template_test.go | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/template.go b/template.go index 7f5e6688f..dcb2c8b17 100644 --- a/template.go +++ b/template.go @@ -60,6 +60,7 @@ func gatherTemplates(o *Config) (templates []*tplate, err error) { templates = []*tplate{{ name: "", contents: o.Input, + mode: os.FileMode(0644), }} if len(o.OutputFiles) == 1 { diff --git a/template_test.go b/template_test.go index a58b0e224..721ba4a5c 100644 --- a/template_test.go +++ b/template_test.go @@ -159,6 +159,15 @@ func TestGatherTemplates(t *testing.T) { assert.Equal(t, "foo", templates[0].contents) assert.Equal(t, Stdout, templates[0].target) + templates, err = gatherTemplates(&Config{ + Input: "foo", + OutputFiles: []string{"out"}, + }) + assert.NoError(t, err) + assert.Len(t, templates, 1) + assert.Equal(t, "out", templates[0].targetPath) + assert.Equal(t, os.FileMode(0644), templates[0].mode) + templates, err = gatherTemplates(&Config{ InputFiles: []string{"foo"}, OutputFiles: []string{"out"},