Skip to content

refactor: Make workspace new use the views package for producing terminal output - #39191

Merged
SarahFrench merged 4 commits into
mainfrom
refactor-workspace-new-use-views
Oct 2, 2026
Merged

SarahFrench merged 4 commits into
mainfrom
refactor-workspace-new-use-views

Conversation

@SarahFrench

Copy link
Copy Markdown
Member

This PR refactors workspace new use the views package for human output.

There are some future changes I want to make in a separate PR that will ensure that all paths through the command result in only a single invocation of a view method, as this is necessary if JSON output will be added to this command in future. But this PR for now maintains the commands structure as-is.

Target Release

1.18.x

Rollback Plan

  • If a change needs to be reverted, we will roll out an update to the code within 7 days.

Changes to Security Controls

Are there any changes to security controls (access controls, encryption, logging) in this pull request? If so, explain.

CHANGELOG entry

  • This change is user-facing and I added a changelog entry.
  • This change is not user-facing.

@SarahFrench SarahFrench added the no-changelog-needed Add this to your PR if the change does not require a changelog entry label Sep 11, 2026
@SarahFrench
SarahFrench force-pushed the refactor-workspace-new-use-views branch 3 times, most recently from 39cc9e7 to 24901e9 Compare September 11, 2026 18:17
@SarahFrench
SarahFrench marked this pull request as ready for review September 30, 2026 16:16
@SarahFrench
SarahFrench requested a review from a team as a code owner September 30, 2026 16:16
austinvalle
austinvalle previously approved these changes Oct 1, 2026

@austinvalle austinvalle left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹

Comment thread internal/command/workspace_new.go Outdated
Comment thread internal/command/workspace_new.go Outdated
Comment thread internal/command/workspace_new.go

c.Ui.Output(c.Colorize().Color(fmt.Sprintf(
strings.TrimSpace(envCreated), workspace)))
view.LogWorkspaceCreationSuccess(workspace, diags)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's interesting that it outputs the success before we're actually done, not that we should change anything in this PR 😆

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have mad deja vu about this, so maybe I have a forgotten branch kicking around to fix this. Ideally there'd be distinct success messages of 1) workspace made or 2) workspace made and populated with state, and then the ability to report a failure to the user where there was the side effect of an empty state being made but failing to populate it with data.

I'll look, but deffo beyond this PRs scope!

@SarahFrench SarahFrench Oct 1, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we go! #39192

I'll rebase etc after this PR and then propose the changes. As this command only makes human output I believe we're free to update output freely like this.

@SarahFrench
SarahFrench marked this pull request as draft October 1, 2026 14:58
Constants used for output are moved into the views package, so _for now_ the old use of `Ui` required importing that const that's been moved.
@SarahFrench
SarahFrench force-pushed the refactor-workspace-new-use-views branch from 24901e9 to 51adef4 Compare October 1, 2026 16:19
@SarahFrench
SarahFrench marked this pull request as ready for review October 1, 2026 16:25
@SarahFrench
SarahFrench force-pushed the refactor-workspace-new-use-views branch from 51adef4 to dd77deb Compare October 1, 2026 16:28
@SarahFrench

Copy link
Copy Markdown
Member Author

Thanks @austinvalle !

@SarahFrench
SarahFrench merged commit b99f64e into main Oct 2, 2026
14 checks passed
@SarahFrench
SarahFrench deleted the refactor-workspace-new-use-views branch October 2, 2026 10:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-changelog-needed Add this to your PR if the change does not require a changelog entry

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants