diff --git a/cmd/tea_plan.go b/cmd/tea_plan.go index 7785904a..3279ab11 100644 --- a/cmd/tea_plan.go +++ b/cmd/tea_plan.go @@ -22,6 +22,7 @@ type runPlanModel struct { args []string planFile string + revlinkTask revlinkWarmupModel taskModel } type runPlanNowMsg struct{} @@ -32,12 +33,16 @@ func NewRunPlanModel(args []string, planFile string) runPlanModel { args: args, planFile: planFile, - taskModel: NewTaskModel("Planning Changes"), + revlinkTask: NewRevlinkWarmupModel(), + taskModel: NewTaskModel("Planning Changes"), } } func (m runPlanModel) Init() tea.Cmd { - return nil + return tea.Batch( + m.revlinkTask.Init(), + m.taskModel.Init(), + ) } func (m runPlanModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { @@ -94,8 +99,12 @@ func (m runPlanModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { // propagate commands to components // m.taskModel, cmd = m.taskModel.Update(msg) // cmds = append(cmds, cmd) - } + + var cmd tea.Cmd + m.revlinkTask, cmd = m.revlinkTask.Update(msg) + cmds = append(cmds, cmd) + return m, tea.Batch(cmds...) } @@ -111,6 +120,7 @@ func (m runPlanModel) View() string { )) case taskStatusDone: bits = append(bits, m.taskModel.View()) + bits = append(bits, m.revlinkTask.View()) case taskStatusError, taskStatusSkipped: // handled by caller } diff --git a/cmd/tea_revlink.go b/cmd/tea_revlink.go index fed96526..db1ac30b 100644 --- a/cmd/tea_revlink.go +++ b/cmd/tea_revlink.go @@ -25,7 +25,7 @@ type revlinkWarmupModel struct { currentStatus *sdp.RevlinkWarmupResponse } -func NewRevlinkWarmupModel() tea.Model { +func NewRevlinkWarmupModel() revlinkWarmupModel { return revlinkWarmupModel{ taskModel: NewTaskModel("Discover and link all resources"), status: make(chan *sdp.RevlinkWarmupResponse), @@ -45,7 +45,7 @@ func (m revlinkWarmupModel) Init() tea.Cmd { return m.taskModel.Init() } -func (m revlinkWarmupModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { +func (m revlinkWarmupModel) Update(msg tea.Msg) (revlinkWarmupModel, tea.Cmd) { cmds := []tea.Cmd{} switch msg := msg.(type) { diff --git a/cmd/tea_terraform.go b/cmd/tea_terraform.go index 122a8e4e..4c302ba6 100644 --- a/cmd/tea_terraform.go +++ b/cmd/tea_terraform.go @@ -62,7 +62,6 @@ func (m cmdModel) Init() tea.Cmd { if viper.GetString("ovm-test-fake") != "" { // don't init sources on test-fake runs // m.tasks["02_config"] = NewInitialiseSourcesModel() - m.tasks["03_revlink"] = NewRevlinkWarmupModel() return tea.Batch( waitForCancellation(m.ctx, m.cancel), m.tasks["00_oi"].Init(), @@ -72,21 +71,18 @@ func (m cmdModel) Init() tea.Cmd { time.Sleep(3 * time.Second) return sourcesInitialisedMsg{} }, - m.tasks["03_revlink"].Init(), m.cmd.Init(), ) } // these wait for taking a ctx until timeout and token are attached m.tasks["02_config"] = NewInitialiseSourcesModel() - m.tasks["03_revlink"] = NewRevlinkWarmupModel() return tea.Batch( waitForCancellation(m.ctx, m.cancel), m.tasks["00_oi"].Init(), m.tasks["01_token"].Init(), m.tasks["02_config"].Init(), - m.tasks["03_revlink"].Init(), m.cmd.Init(), ) }