File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change 7
7
"github.com/BurntSushi/toml"
8
8
"github.com/fsouza/go-dockerclient"
9
9
"io"
10
+ "io/ioutil"
10
11
"net"
11
12
"net/http"
12
13
"net/http/httputil"
@@ -145,9 +146,10 @@ func generateFile(config Config, containers []*RuntimeContainer) {
145
146
tmpl = tmpl
146
147
dest := os .Stdout
147
148
if config .Dest != "" {
148
- dest , err = os .Create (config .Dest )
149
+ dest , err = ioutil .TempFile ("" , "docker-gen" )
150
+ defer dest .Close ()
149
151
if err != nil {
150
- fmt .Println ("unable to create dest file %s : %s\n " , config . Dest , err )
152
+ fmt .Println ("unable to create temp file: %s\n " , err )
151
153
os .Exit (1 )
152
154
}
153
155
}
@@ -156,6 +158,15 @@ func generateFile(config Config, containers []*RuntimeContainer) {
156
158
if err != nil {
157
159
fmt .Printf ("template error: %s\n " , err )
158
160
}
161
+
162
+ if config .Dest != "" {
163
+ err = os .Rename (dest .Name (), config .Dest )
164
+ if err != nil {
165
+ fmt .Println ("unable to create dest file %s: %s\n " , config .Dest , err )
166
+ os .Exit (1 )
167
+ }
168
+ }
169
+
159
170
}
160
171
161
172
func newConn () (* httputil.ClientConn , error ) {
You can’t perform that action at this time.
0 commit comments