Skip to content

Commit

Permalink
fix: use temporary file for secret file to prevent deletion collision (
Browse files Browse the repository at this point in the history
…#250)

Fixes #167
  • Loading branch information
sstarcher authored and mumoshu committed Aug 30, 2018
1 parent 822cc13 commit 9b71c64
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion helmexec/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package helmexec

import (
"io"
"io/ioutil"
"os"
"strings"

"go.uber.org/zap"
Expand Down Expand Up @@ -102,7 +104,19 @@ func (helm *execer) DecryptSecret(name string) (string, error) {
helm.logger.Infof("Decrypting secret %v", name)
out, err := helm.exec(append([]string{"secrets", "dec", name})...)
helm.write(out)
return name + ".dec", err

tmpFile, err := ioutil.TempFile("", "secret")
if err != nil {
return "", err
}
tmpFile.Close()

err = os.Rename(name+".dec", tmpFile.Name())
if err != nil {
return "", err
}

return tmpFile.Name(), err
}

func (helm *execer) DiffRelease(name, chart string, flags ...string) error {
Expand Down

0 comments on commit 9b71c64

Please sign in to comment.