Skip to content

Commit

Permalink
Merge branch 'JustAdam-generatefile-fix'
Browse files Browse the repository at this point in the history
  • Loading branch information
jwilder committed Oct 1, 2014
2 parents 0cf31ba + 885b59f commit 1b6ec01
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion template.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"os"
"path/filepath"
"strings"
"syscall"
"text/template"
)

Expand Down Expand Up @@ -108,7 +109,13 @@ func generateFile(config Config, containers Context) bool {
if config.Dest != "" {

contents := []byte{}
if _, err := os.Stat(config.Dest); err == nil {
if fi, err := os.Stat(config.Dest); err == nil {
if err := dest.Chmod(fi.Mode()); err != nil {
log.Fatalf("unable to chmod temp file: %s\n", err)
}
if err := dest.Chown(int(fi.Sys().(*syscall.Stat_t).Uid), int(fi.Sys().(*syscall.Stat_t).Gid)); err != nil {
log.Fatalf("unable to chown temp file: %s\n", err)
}
contents, err = ioutil.ReadFile(config.Dest)
if err != nil {
log.Fatalf("unable to compare current file contents: %s: %s\n", config.Dest, err)
Expand Down

0 comments on commit 1b6ec01

Please sign in to comment.