fix: avoid "cross-device link" errors while decrypting secrets (#260)

ref https://github.com/roboll/helmfile/issues/251#issuecomment-417166296
This commit is contained in:
KUOKA Yusuke 2018-08-30 17:20:38 +09:00 committed by GitHub
parent 0c8a89cbaf
commit 79f0e70ce8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 2 deletions

View File

@ -115,9 +115,18 @@ func (helm *execer) DecryptSecret(name string) (string, error) {
if err != nil {
return "", err
}
tmpFile.Close()
defer tmpFile.Close()
err = os.Rename(name+".dec", tmpFile.Name())
// os.Rename seems to results in "cross-device link` errors in some cases
// Instead of moving, copy it to the destination temp file as a work-around
// See https://github.com/roboll/helmfile/issues/251#issuecomment-417166296
decFile, err := os.Open(name + ".dec")
if err != nil {
return "", err
}
defer decFile.Close()
_, err = io.Copy(tmpFile, decFile)
if err != nil {
return "", err
}