Skip to content
This repository has been archived by the owner on Jun 17, 2022. It is now read-only.

Commit

Permalink
Fix race condition
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Allen committed May 7, 2020
1 parent 96049e0 commit d420841
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions deploy/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

var fileCache = make(map[string][]byte)

type clusterJob struct {
*clusterConfig
Secrets []*secretConfig
Expand Down Expand Up @@ -62,17 +60,12 @@ func (j *clusterJob) Run() {
func (j *clusterJob) setData(secret *v1.Secret, files map[string]string, logger *log.Entry) bool {
dataMap := make(map[string][]byte)
hasErrors := false

for k, v := range files {
data, ok := fileCache[v]
if !ok {
data, err := ioutil.ReadFile(v)
if err != nil {
logger.Error(err)
hasErrors = true
continue
}
fileCache[v] = data
data, err := ioutil.ReadFile(v)
if err != nil {
logger.Error(err)
hasErrors = true
continue
}
dataMap[k] = data
}
Expand Down

0 comments on commit d420841

Please sign in to comment.