From d4208417c0f37432b96208824f62235770eada0d Mon Sep 17 00:00:00 2001 From: Chris Allen Date: Thu, 7 May 2020 11:18:47 -0500 Subject: [PATCH] Fix race condition --- deploy/job.go | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/deploy/job.go b/deploy/job.go index ddf134d..8a67fd0 100644 --- a/deploy/job.go +++ b/deploy/job.go @@ -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 @@ -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 }