Skip to content

Commit a34812c

Browse files
author
Lauren
committed
call Colorize() on CLI output
1 parent 8da1c00 commit a34812c

File tree

4 files changed

+9
-7
lines changed

4 files changed

+9
-7
lines changed

internal/backend/remote/backend_common.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,8 @@ func (b *Remote) checkPolicy(stopCtx, cancelCtx context.Context, op *backend.Ope
419419
case tfe.PolicyHardFailed:
420420
return fmt.Errorf(msgPrefix + " hard failed.")
421421
case tfe.PolicySoftFailed:
422-
runUrl := fmt.Sprintf(runHeader, b.hostname, b.organization, op.Workspace, r.ID)
422+
runUrl := b.Colorize().Color(strings.TrimSpace(fmt.Sprintf(runHeader, b.hostname, b.organization, op.Workspace, r.ID)) + "\n")
423+
b.CLI.Output(runUrl)
423424

424425
if op.Type == backend.OperationTypePlan || op.UIOut == nil || op.UIIn == nil ||
425426
!pc.Actions.IsOverridable || !pc.Permissions.CanOverride {

internal/backend/remote/backend_plan.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -443,8 +443,8 @@ Preparing the remote plan...
443443
`
444444

445445
const runHeader = `
446-
[reset][yellow]To view this run in a browser, visit:
447-
https://%s/app/%s/%s/runs/%s[reset]
446+
[reset][yellow]To view this run in a browser, visit:[reset]
447+
[reset][yellow]https://%s/app/%s/%s/runs/%s[reset]
448448
`
449449

450450
// The newline in this error is to make it look good in the CLI!

internal/cloud/backend_common.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,8 @@ func (b *Cloud) checkPolicy(stopCtx, cancelCtx context.Context, op *backend.Oper
391391
case tfe.PolicyHardFailed:
392392
return fmt.Errorf(msgPrefix + " hard failed.")
393393
case tfe.PolicySoftFailed:
394-
runUrl := fmt.Sprintf(runHeader, b.Hostname, b.Organization, op.Workspace, r.ID)
394+
runUrl := b.Colorize().Color(strings.TrimSpace(fmt.Sprintf(runHeader, b.Hostname, b.Organization, op.Workspace, r.ID)) + "\n")
395+
b.CLI.Output(runUrl)
395396

396397
if op.Type == backend.OperationTypePlan || op.UIOut == nil || op.UIIn == nil ||
397398
!pc.Actions.IsOverridable || !pc.Permissions.CanOverride {

internal/cloud/backend_plan.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ func (b *Cloud) renderPlanLogs(ctx context.Context, op *backend.Operation, run *
468468
// print the line. This maintains backwards compatibility for
469469
// users who do not wish to enable structured output in their
470470
// workspace.
471-
b.CLI.Output(string(line))
471+
b.CLI.Output(b.Colorize().Color(string(line)))
472472
continue
473473
}
474474

@@ -638,8 +638,8 @@ Preparing the remote plan...
638638
`
639639

640640
const runHeader = `
641-
[reset][yellow]To view this run in a browser, visit:
642-
https://%s/app/%s/%s/runs/%s[reset]
641+
[reset][yellow]To view this run in a browser, visit:[reset]
642+
[reset][yellow]https://%s/app/%s/%s/runs/%s[reset]
643643
`
644644

645645
// The newline in this error is to make it look good in the CLI!

0 commit comments

Comments
 (0)