Skip to content

Commit

Permalink
Merge pull request #352 from nginx-proxy/permissions
Browse files Browse the repository at this point in the history
Make sure file generated by docker-gen has the right permission
  • Loading branch information
buchdag authored Jun 15, 2021
2 parents e585ae4 + cd1932e commit 75b892d
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion template.go
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,16 @@ func GenerateFile(config Config, containers Context) bool {
}

oldContents := []byte{}
if fi, err := os.Stat(config.Dest); err == nil {
if fi, err := os.Stat(config.Dest); err == nil || os.IsNotExist(err) {
if err != nil && os.IsNotExist(err) {
emptyFile, err := os.Create(config.Dest)
if err != nil {
log.Fatalf("Unable to create empty destination file: %s\n", err)
} else {
emptyFile.Close()
fi, err = os.Stat(config.Dest)
}
}
if err := dest.Chmod(fi.Mode()); err != nil {
log.Fatalf("Unable to chmod temp file: %s\n", err)
}
Expand Down

0 comments on commit 75b892d

Please sign in to comment.