func (s startUniter) step(c *gc.C, ctx *context) { if s.unitTag == "" { s.unitTag = "unit-u-0" } if ctx.uniter != nil { panic("don't start two uniters!") } if ctx.api == nil { panic("API connection not established") } tag, err := names.ParseUnitTag(s.unitTag) if err != nil { panic(err.Error()) } locksDir := filepath.Join(ctx.dataDir, "locks") lock, err := fslock.NewLock(locksDir, "uniter-hook-execution") c.Assert(err, jc.ErrorIsNil) uniterParams := uniter.UniterParams{ St: ctx.api, UnitTag: tag, LeadershipManager: ctx.leader, DataDir: ctx.dataDir, HookLock: lock, MetricsTimerChooser: uniter.NewTestingMetricsTimerChooser( ctx.collectMetricsTicker.ReturnTimer, ctx.sendMetricsTicker.ReturnTimer, ), UpdateStatusSignal: ctx.updateStatusHookTicker.ReturnTimer, NewOperationExecutor: s.newExecutorFunc, } ctx.uniter = uniter.NewUniter(&uniterParams) uniter.SetUniterObserver(ctx.uniter, ctx) }
func (s startUniter) step(c *gc.C, ctx *context) { if s.unitTag == "" { s.unitTag = "unit-u-0" } if ctx.uniter != nil { panic("don't start two uniters!") } if ctx.api == nil { panic("API connection not established") } tag, err := names.ParseUnitTag(s.unitTag) if err != nil { panic(err.Error()) } locksDir := filepath.Join(ctx.dataDir, "locks") lock, err := fslock.NewLock(locksDir, "uniter-hook-execution") c.Assert(err, jc.ErrorIsNil) uniterParams := uniter.UniterParams{ ctx.api, tag, ctx.leader, ctx.dataDir, lock, uniter.NewTestingMetricsTimerChooser(ctx.metricsTicker.ReturnTimer), ctx.updateStatusHookTicker.ReturnTimer, } ctx.uniter = uniter.NewUniter(&uniterParams) uniter.SetUniterObserver(ctx.uniter, ctx) }