Skip to content

Commit

Permalink
fix "concurrent map read/write" panics
Browse files Browse the repository at this point in the history
Fixes #737
  • Loading branch information
mumoshu committed Jul 3, 2019
1 parent b82f77e commit 7f2d006
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/state/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"sort"
"strconv"
"strings"
"sync"

"github.com/roboll/helmfile/pkg/environment"
"github.com/roboll/helmfile/pkg/event"
Expand Down Expand Up @@ -58,6 +59,9 @@ type HelmState struct {
tempDir func(string, string) (string, error)

runner helmexec.Runner

vals map[string]interface{}
valsMutex sync.Mutex
}

// SubHelmfileSpec defines the subhelmfile path and options
Expand Down
8 changes: 8 additions & 0 deletions pkg/state/state_exec_tmpl.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ import (
)

func (st *HelmState) Values() (map[string]interface{}, error) {
st.valsMutex.Lock()
defer st.valsMutex.Unlock()
if st.vals != nil {
return st.vals, nil
}

vals := map[string]interface{}{}

if err := mergo.Merge(&vals, st.Env.Defaults, mergo.WithOverride); err != nil {
Expand All @@ -22,6 +28,8 @@ func (st *HelmState) Values() (map[string]interface{}, error) {
return nil, err
}

st.vals = vals

return vals, nil
}

Expand Down

0 comments on commit 7f2d006

Please sign in to comment.