From 498e93c3f229a52990ff1b25a615c252de3a00e4 Mon Sep 17 00:00:00 2001 From: David Gageot Date: Mon, 18 May 2020 23:18:58 +0200 Subject: [PATCH] Simpler code for changeset Signed-off-by: David Gageot --- pkg/skaffold/runner/changeset.go | 8 ++++++++ pkg/skaffold/runner/new.go | 6 +----- pkg/skaffold/runner/runner.go | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/pkg/skaffold/runner/changeset.go b/pkg/skaffold/runner/changeset.go index d2b18133fd1..fdec275b265 100644 --- a/pkg/skaffold/runner/changeset.go +++ b/pkg/skaffold/runner/changeset.go @@ -34,6 +34,10 @@ func (c *changeSet) AddRebuild(a *latest.Artifact) { if _, ok := c.rebuildTracker[a.ImageName]; ok { return } + + if c.rebuildTracker == nil { + c.rebuildTracker = map[string]*latest.Artifact{} + } c.rebuildTracker[a.ImageName] = a c.needsRebuild = append(c.needsRebuild, a) c.needsRedeploy = true @@ -43,6 +47,10 @@ func (c *changeSet) AddResync(s *sync.Item) { if _, ok := c.resyncTracker[s.Image]; ok { return } + + if c.resyncTracker == nil { + c.resyncTracker = map[string]*sync.Item{} + } c.resyncTracker[s.Image] = s c.needsResync = append(c.needsResync, s) } diff --git a/pkg/skaffold/runner/new.go b/pkg/skaffold/runner/new.go index 5586d090218..e9b1d8089f2 100644 --- a/pkg/skaffold/runner/new.go +++ b/pkg/skaffold/runner/new.go @@ -111,11 +111,7 @@ func NewForConfig(runCtx *runcontext.RunContext) (*SkaffoldRunner, error) { Trigger: trigger, intentChan: intentChan, }, - kubectlCLI: kubectlCLI, - changeSet: &changeSet{ - rebuildTracker: make(map[string]*latest.Artifact), - resyncTracker: make(map[string]*sync.Item), - }, + kubectlCLI: kubectlCLI, labellers: labellers, defaultLabeller: defaultLabeller, podSelector: kubernetes.NewImageList(), diff --git a/pkg/skaffold/runner/runner.go b/pkg/skaffold/runner/runner.go index 018d6d6822d..be33981bbfc 100644 --- a/pkg/skaffold/runner/runner.go +++ b/pkg/skaffold/runner/runner.go @@ -60,7 +60,7 @@ type SkaffoldRunner struct { kubectlCLI *kubectl.CLI cache cache.Cache - changeSet *changeSet + changeSet changeSet runCtx *runcontext.RunContext labellers []deploy.Labeller defaultLabeller *deploy.DefaultLabeller