diff --git a/editor.go b/editor.go index fc368a3..6af3367 100644 --- a/editor.go +++ b/editor.go @@ -8,8 +8,6 @@ import ( "os" "os/exec" "strings" - - "github.com/google/uuid" ) const ( @@ -55,12 +53,7 @@ func (e Editor) Launch(path string) error { } func (e Editor) LaunchTemp(r io.Reader) ([]byte, string, error) { - uuid, err := uuid.NewRandom() - if err != nil { - return []byte{}, "", err - } - tmpf := fmt.Sprintf("/dev/shm/%v", uuid) - f, err := os.OpenFile(tmpf, os.O_RDWR|os.O_CREATE, 0600) + f, err := ioutil.TempFile("", "*.helm") if err != nil { return nil, "", err } diff --git a/wrapper.go b/wrapper.go index 059227c..6c5bb3b 100644 --- a/wrapper.go +++ b/wrapper.go @@ -7,7 +7,6 @@ import ( "os/exec" "strings" - "github.com/google/uuid" log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -185,22 +184,15 @@ func decryptSecrets(args []string) ([]string, []string, error) { if err != nil { return helmArgs, decryptedFiles, err } - // Store decrypted contents in a shm file - uuid, err := uuid.NewRandom() - if err != nil { - return helmArgs, decryptedFiles, err - } - tmpf := fmt.Sprintf("/dev/shm/%v", uuid) + // Store decrypted contents in a tmp file + f, err := ioutil.TempFile("", "*.helm") + tmpf := f.Name() decryptedFiles = append(decryptedFiles, tmpf) - _, err = os.OpenFile(tmpf, os.O_RDWR|os.O_CREATE, 0600) - if err != nil { - return helmArgs, decryptedFiles, err - } - err = ioutil.WriteFile(tmpf, plain, 0644) + _, err = f.Write(plain) if err != nil { return helmArgs, decryptedFiles, err } - // Update args to access the decrypt shm file instead + // Update args to access the decrypt tmp file instead helmArgs[i+1] = tmpf } }