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/zapcore"
"sync"
)
const (
@ -15,11 +16,12 @@ const (
)
type execer struct {
helmBinary string
runner Runner
logger *zap.SugaredLogger
kubeContext string
extra []string
helmBinary string
runner Runner
logger *zap.SugaredLogger
kubeContext string
extra []string
decryptionMutex sync.Mutex
}
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) {
// Prevents https://github.com/roboll/helmfile/issues/258
helm.decryptionMutex.Lock()
defer helm.decryptionMutex.Unlock()
helm.logger.Infof("Decrypting secret %v", name)
out, err := helm.exec(append([]string{"secrets", "dec", name})...)
helm.write(out)