Skip to content

Commit 7f2d006

Browse files
committed
fix "concurrent map read/write" panics
Fixes #737
1 parent b82f77e commit 7f2d006

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

pkg/state/state.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"sort"
1111
"strconv"
1212
"strings"
13+
"sync"
1314

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

6061
runner helmexec.Runner
62+
63+
vals map[string]interface{}
64+
valsMutex sync.Mutex
6165
}
6266

6367
// SubHelmfileSpec defines the subhelmfile path and options

pkg/state/state_exec_tmpl.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ import (
88
)
99

1010
func (st *HelmState) Values() (map[string]interface{}, error) {
11+
st.valsMutex.Lock()
12+
defer st.valsMutex.Unlock()
13+
if st.vals != nil {
14+
return st.vals, nil
15+
}
16+
1117
vals := map[string]interface{}{}
1218

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

31+
st.vals = vals
32+
2533
return vals, nil
2634
}
2735

0 commit comments

Comments
 (0)