File tree Expand file tree Collapse file tree 1 file changed +2
-16
lines changed Expand file tree Collapse file tree 1 file changed +2
-16
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,6 @@ package main
2
2
3
3
import (
4
4
"bytes"
5
- "io"
6
5
"io/ioutil"
7
6
"log"
8
7
"os"
@@ -85,21 +84,8 @@ func generateFile(config Config, containers Context) bool {
85
84
filteredContainers = containers
86
85
}
87
86
88
- dest := os .Stdout
89
- if config .Dest != "" {
90
- dest , err = ioutil .TempFile (filepath .Dir (config .Dest ), "docker-gen" )
91
- defer func () {
92
- dest .Close ()
93
- os .Remove (dest .Name ())
94
- }()
95
- if err != nil {
96
- log .Fatalf ("unable to create temp file: %s\n " , err )
97
- }
98
- }
99
-
100
87
var buf bytes.Buffer
101
- multiwriter := io .MultiWriter (dest , & buf )
102
- err = tmpl .ExecuteTemplate (multiwriter , filepath .Base (templatePath ), & filteredContainers )
88
+ err = tmpl .ExecuteTemplate (& buf , filepath .Base (templatePath ), & filteredContainers )
103
89
if err != nil {
104
90
log .Fatalf ("template error: %s\n " , err )
105
91
}
@@ -115,7 +101,7 @@ func generateFile(config Config, containers Context) bool {
115
101
}
116
102
117
103
if bytes .Compare (contents , buf .Bytes ()) != 0 {
118
- err = os . Rename ( dest . Name (), config . Dest )
104
+ err = ioutil . WriteFile ( config . Dest , buf . Bytes (), os . FileMode ( 0640 ) )
119
105
if err != nil {
120
106
log .Fatalf ("unable to create dest file %s: %s\n " , config .Dest , err )
121
107
}
You can’t perform that action at this time.
0 commit comments