Skip to content

Commit

Permalink
engine: separate out Cmd creation from Cmd running (#4289)
Browse files Browse the repository at this point in the history
ServerController is getting closer to what typical "user-authored" controller will look like.
It doesn't manage any work directly - it simply creates new Cmd objects that do the real work.
  • Loading branch information
nicks committed Mar 10, 2021
1 parent 839a38f commit 2b7b0c4
Show file tree
Hide file tree
Showing 13 changed files with 371 additions and 168 deletions.
1 change: 1 addition & 0 deletions internal/cli/wire.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ var BaseWireSet = wire.NewSet(
local.ProvideExecer,
local.ProvideProberManager,
local.NewController,
local.NewServerController,
k8swatch.NewPodWatcher,
k8swatch.NewServiceWatcher,
k8swatch.NewEventWatchManager,
Expand Down
8 changes: 5 additions & 3 deletions internal/cli/wire_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 28 additions & 4 deletions internal/engine/local/actions.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package local

import "github.com/tilt-dev/tilt/internal/store"

type CmdCreateAction struct {
Cmd *Cmd
}
Expand All @@ -8,14 +10,36 @@ func NewCmdCreateAction(cmd *Cmd) CmdCreateAction {
return CmdCreateAction{Cmd: cmd.DeepCopy()}
}

var _ store.Summarizer = CmdCreateAction{}

func (CmdCreateAction) Action() {}

type CmdUpdateAction struct {
func (a CmdCreateAction) Summarize(s *store.ChangeSummary) {
if s.CmdSpecs == nil {
s.CmdSpecs = make(map[string]bool)
}
s.CmdSpecs[a.Cmd.Name] = true
}

type CmdUpdateStatusAction struct {
Cmd *Cmd
}

func NewCmdUpdateAction(cmd *Cmd) CmdUpdateAction {
return CmdUpdateAction{Cmd: cmd.DeepCopy()}
func NewCmdUpdateStatusAction(cmd *Cmd) CmdUpdateStatusAction {
return CmdUpdateStatusAction{Cmd: cmd.DeepCopy()}
}

func (CmdUpdateAction) Action() {}
func (CmdUpdateStatusAction) Action() {}

type CmdDeleteAction struct {
Name string
}

func (CmdDeleteAction) Action() {}

func (a CmdDeleteAction) Summarize(s *store.ChangeSummary) {
if s.CmdSpecs == nil {
s.CmdSpecs = make(map[string]bool)
}
s.CmdSpecs[a.Name] = true
}

0 comments on commit 2b7b0c4

Please sign in to comment.