fix: coordinate secret decryption (#259)

Fixes #258
This commit is contained in:
KUOKA Yusuke 2018-08-30 17:03:45 +09:00 committed by GitHub
parent b3ebd4cdd0
commit 0c8a89cbaf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 5 deletions

View File

@ -8,6 +8,7 @@ import (
"go.uber.org/zap" "go.uber.org/zap"
"go.uber.org/zap/zapcore" "go.uber.org/zap/zapcore"
"sync"
) )
const ( const (
@ -20,6 +21,7 @@ type execer struct {
logger *zap.SugaredLogger logger *zap.SugaredLogger
kubeContext string kubeContext string
extra []string extra []string
decryptionMutex sync.Mutex
} }
func NewLogger(writer io.Writer, logLevel string) *zap.SugaredLogger { func NewLogger(writer io.Writer, logLevel string) *zap.SugaredLogger {
@ -101,6 +103,10 @@ func (helm *execer) ReleaseStatus(name string) error {
} }
func (helm *execer) DecryptSecret(name string) (string, error) { func (helm *execer) DecryptSecret(name string) (string, error) {
// Prevents https://github.com/roboll/helmfile/issues/258
helm.decryptionMutex.Lock()
defer helm.decryptionMutex.Unlock()
helm.logger.Infof("Decrypting secret %v", name) helm.logger.Infof("Decrypting secret %v", name)
out, err := helm.exec(append([]string{"secrets", "dec", name})...) out, err := helm.exec(append([]string{"secrets", "dec", name})...)
helm.write(out) helm.write(out)