Skip to content

Commit

Permalink
Simpler code for changeset
Browse files Browse the repository at this point in the history
Signed-off-by: David Gageot <david@gageot.net>
  • Loading branch information
dgageot committed May 19, 2020
1 parent e9f74c6 commit 498e93c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
8 changes: 8 additions & 0 deletions pkg/skaffold/runner/changeset.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
}
Expand Down
6 changes: 1 addition & 5 deletions pkg/skaffold/runner/new.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
2 changes: 1 addition & 1 deletion pkg/skaffold/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 498e93c

Please sign in to comment.