Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

terraform-workspace: use TF CLI #311

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

v0id3r
Copy link

@v0id3r v0id3r commented Apr 30, 2021

No description provided.

@justjanne
Copy link
Owner

Could you please explain in more detail why you believe this is needed? Spawning an additional process tends to increase latency quite a bit, so we try to avoid that unless necessary

@5HT2
Copy link

5HT2 commented Oct 15, 2024

The only reason I can see to do this is if c.Workspace()1 has some kind of side-effect that does a refresh, or ensures that the current selected workspace still exists?

If that is the case, it would probably be better to implement a proper check to refresh the workspace if, say, a lock file has changed or similar, the PR itself seems kind of redundant.

func (c *WorkspaceShowCommand) Run(args []string) int {
	args = c.Meta.process(args)
	cmdFlags := c.Meta.extendedFlagSet("workspace show")
	cmdFlags.Usage = func() { c.Ui.Error(c.Help()) }
	if err := cmdFlags.Parse(args); err != nil {
		c.Ui.Error(fmt.Sprintf("Error parsing command-line flags: %s\n", err.Error()))
		return 1
	}


	workspace, err := c.Workspace()
	if err != nil {
		c.Ui.Error(fmt.Sprintf("Error selecting workspace: %s", err))
		return 1
	}
	c.Ui.Output(workspace)


	return 0
}

Footnotes

  1. hashicorp/terraform/internal/command/workspace_show.go#L17-L34

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants