Skip to content

Commit

Permalink
pr fix: undo removal of inited
Browse files Browse the repository at this point in the history
  • Loading branch information
paul-rodriguez committed Aug 21, 2023
1 parent df46e41 commit f599ab1
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions internals/overlord/overlord.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ type Overlord struct {
pruneTicker *time.Ticker

// managers
inited bool
runner *state.TaskRunner
serviceMgr *servstate.ServiceManager
commandMgr *cmdstate.CommandManager
Expand All @@ -77,6 +78,7 @@ func New(pebbleDir string, restartHandler restart.Handler, serviceOutput io.Writ
o := &Overlord{
pebbleDir: pebbleDir,
loopTomb: new(tomb.Tomb),
inited: true,
}

if !filepath.IsAbs(pebbleDir) {
Expand Down Expand Up @@ -424,14 +426,20 @@ func Fake() *Overlord {
func FakeWithState(handleRestart func(restart.RestartType)) *Overlord {
o := &Overlord{
loopTomb: new(tomb.Tomb),
inited: false,
}
s := state.New(fakeBackend{o: o})
o.stateEng = NewStateEngine(s)
o.runner = state.NewTaskRunner(s)
return o
}

// AddManager adds a manager to a fake overlord. It cannot be used for
// a normally initialized overlord those are already fully populated.
func (o *Overlord) AddManager(mgr StateManager) {
if o.inited {
panic("internal error: cannot add managers to a fully initialized Overlord")
}
o.addManager(mgr)
}

Expand Down

0 comments on commit f599ab1

Please sign in to comment.