From bba03384d5d2b9bc456a3f08adb4ad03f0a1db4a Mon Sep 17 00:00:00 2001 From: Sander van Harmelen Date: Tue, 8 Jan 2019 16:55:21 +0100 Subject: [PATCH] backend/remote: log early to indicate execution started --- backend/remote/backend_apply.go | 6 +++--- backend/remote/backend_plan.go | 23 ++++++++++++++++------- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/backend/remote/backend_apply.go b/backend/remote/backend_apply.go index 4d78a0437..5add95c48 100644 --- a/backend/remote/backend_apply.go +++ b/backend/remote/backend_apply.go @@ -225,7 +225,7 @@ func (b *Remote) opApply(stopCtx, cancelCtx context.Context, op *backend.Operati const applyDefaultHeader = ` [reset][yellow]Running apply in the remote backend. Output will stream here. Pressing Ctrl-C will cancel the remote apply if its still pending. If the apply started it -will stop streaming the logs, but will not stop the apply running remotely. -To view this run in a browser, visit: -https://%s/app/%s/%s/runs/%s[reset] +will stop streaming the logs, but will not stop the apply running remotely.[reset] + +Preparing the remote apply... ` diff --git a/backend/remote/backend_plan.go b/backend/remote/backend_plan.go index 16eeb19c5..bca92dd56 100644 --- a/backend/remote/backend_plan.go +++ b/backend/remote/backend_plan.go @@ -117,6 +117,14 @@ func (b *Remote) opPlan(stopCtx, cancelCtx context.Context, op *backend.Operatio } func (b *Remote) plan(stopCtx, cancelCtx context.Context, op *backend.Operation, w *tfe.Workspace) (*tfe.Run, error) { + if b.CLI != nil { + header := planDefaultHeader + if op.Type == backend.OperationTypeApply { + header = applyDefaultHeader + } + b.CLI.Output(b.Colorize().Color(strings.TrimSpace(header) + "\n")) + } + configOptions := tfe.ConfigurationVersionCreateOptions{ AutoQueueRuns: tfe.Bool(false), Speculative: tfe.Bool(op.Type == backend.OperationTypePlan), @@ -232,12 +240,8 @@ func (b *Remote) plan(stopCtx, cancelCtx context.Context, op *backend.Operation, } if b.CLI != nil { - header := planDefaultHeader - if op.Type == backend.OperationTypeApply { - header = applyDefaultHeader - } b.CLI.Output(b.Colorize().Color(strings.TrimSpace(fmt.Sprintf( - header, b.hostname, b.organization, op.Workspace, r.ID)) + "\n")) + runHeader, b.hostname, b.organization, op.Workspace, r.ID)) + "\n")) } r, err = b.waitForRun(stopCtx, cancelCtx, op, "plan", r, w) @@ -286,8 +290,13 @@ func (b *Remote) plan(stopCtx, cancelCtx context.Context, op *backend.Operation, const planDefaultHeader = ` [reset][yellow]Running plan in the remote backend. Output will stream here. Pressing Ctrl-C -will stop streaming the logs, but will not stop the plan running remotely. -To view this run in a browser, visit: +will stop streaming the logs, but will not stop the plan running remotely.[reset] + +Preparing the remote plan... +` + +const runHeader = ` +[reset][yellow]To view this run in a browser, visit: https://%s/app/%s/%s/runs/%s[reset] `