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

Fix taint and untaint commands when in a workspace #22467

Merged
merged 2 commits into from
Sep 28, 2020

Conversation

kulinacs
Copy link
Contributor

Fixes #22157. Removes DefaultStateFilepath as the default for the
-state flag, allowing workspaces to be used properly.

@atecce
Copy link

atecce commented Sep 25, 2019

🚢 🚢 🚢 :D

@lanoxx
Copy link

lanoxx commented Nov 11, 2019

Is this going to be considered for one of the upcoming 0.12.x patch releases?

@KptnKMan
Copy link

KptnKMan commented Feb 4, 2020

It would be really great if this would be included in the next release.
This has been an issue for a long time now.

@phil-bee
Copy link

phil-bee commented Sep 4, 2020

It would be great if this could be included in the next release.

@pselle pselle requested a review from a team September 25, 2020 20:17
Copy link
Contributor

@mildwonkey mildwonkey left a comment

Choose a reason for hiding this comment

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

Thanks for working on this, @kulinacs ! The changes look great, but I've requested changes to the tests.

The test changes are absolutely not something we'd expect a community contributor to know, and if you'd rather work on that part I'd be happy to re-write the tests using our more modern types for you. (states.State instead of terraform.State, and if you' think that's confusing WELCOME TO MY EVERY DAY 😉 )

Thanks again!

defer testFixCwd(t, tmp, cwd)

// Write the temp state
state := &terraform.State{
Copy link
Contributor

Choose a reason for hiding this comment

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

This is absolutely something a developer would not know if they weren't writing this full-time, but we prefer to use states.State when writing tests post-v0.12. This also removes the need for testStateFileWorkspaceDefault:

	state := states.BuildState(func(s *states.SyncState) {
		s.SetResourceInstanceCurrent(
			addrs.Resource{
				Mode: addrs.ManagedResourceMode,
				Type: "test_instance",
				Name: "bar",
			}.Instance(addrs.NoKey).Absolute(addrs.RootModuleInstance),
			&states.ResourceInstanceObjectSrc{
				AttrsJSON: []byte(`{"id":"bar"}`),
				Status:    states.ObjectReady,
			},
			addrs.AbsProviderConfig{
				Provider: addrs.NewDefaultProvider("test"),
				Module:   addrs.RootModule,
			},
		)
	})
	path := testStateFile(t, state)

@mildwonkey mildwonkey self-assigned this Sep 28, 2020
@kulinacs
Copy link
Contributor Author

Thanks for working on this, @kulinacs ! The changes look great, but I've requested changes to the tests.

The test changes are absolutely not something we'd expect a community contributor to know, and if you'd rather work on that part I'd be happy to re-write the tests using our more modern types for you. (states.State instead of terraform.State, and if you' think that's confusing WELCOME TO MY EVERY DAY 😉 )

Thanks again!

I'd greatly appreciate it if you'd re-write the tests for me. It's been a while since I've looked at the Terraform code and I don't want this PR blocked on me figuring out the type changes 😁

kulinacs and others added 2 commits September 28, 2020 11:44
Fixes hashicorp#22157. Removes DefaultStateFilepath as the default for the
-state flag, allowing workspaces to be used properly.
@mildwonkey
Copy link
Contributor

Apologies for the bad commit, I made a slight mess while rebasing against upstream :) hang tight, sorry for the extra noise!

@codecov
Copy link

codecov bot commented Sep 28, 2020

Codecov Report

Merging #22467 into master will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted Files Coverage Δ
command/taint.go 39.24% <100.00%> (ø)
command/untaint.go 37.32% <100.00%> (ø)
terraform/node_resource_plan.go 97.63% <0.00%> (+1.57%) ⬆️

Copy link
Contributor

@mildwonkey mildwonkey left a comment

Choose a reason for hiding this comment

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

Looks great, thanks!
I rebased your fork's taint-workspace branch against the upstream before modifying the tests, which wasn't strictly necessary. I apologize if I've messed up your fork at all (I'm having a bit of A Day in github).

@mildwonkey mildwonkey merged commit 529ee04 into hashicorp:master Sep 28, 2020
@ghost
Copy link

ghost commented Oct 29, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked as resolved and limited conversation to collaborators Oct 29, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

taint command doesn't recognize tfstate in workspace
7 participants