-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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: atlantis import on workspaces #2937
Conversation
68c2348
to
5b48836
Compare
5b48836
to
7d12f31
Compare
@@ -100,59 +104,7 @@ func (p *PlanStepRunner) remotePlan(ctx command.ProjectContext, extraArgs []stri | |||
return p.fmtPlanOutput(output, tfVersion), nil | |||
} | |||
|
|||
// switchWorkspace changes the terraform workspace if necessary and will create | |||
// it if it doesn't exist. It handles differences between versions. | |||
func (p *PlanStepRunner) switchWorkspace(ctx command.ProjectContext, path string, tfVersion *version.Version, envs map[string]string) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this logic is moved into workspace_step_runner_delegate.go
(_delegate.go
is used like minimum_version_step_runner_delegate.go)
@@ -24,358 +25,12 @@ import ( | |||
. "github.com/runatlantis/atlantis/testing" | |||
) | |||
|
|||
func TestRun_NoWorkspaceIn08(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these tests are test for workspace, so moved into workspace_step_runner_delegate_test.go
@@ -57,6 +59,22 @@ type Runner interface { | |||
Run(ctx command.ProjectContext, extraArgs []string, path string, envs map[string]string) (string, error) | |||
} | |||
|
|||
// NullRunner is a runner that isn't configured for a given plan type but outputs nothing | |||
type NullRunner struct{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just moved
. "github.com/runatlantis/atlantis/testing" | ||
) | ||
|
||
func TestRun_NoWorkspaceIn08(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just moved from plan_step_runner_test.go
terraformExecutor: terraformExecutor, | ||
defaultTFVersion: defaultTfVersion, | ||
} | ||
return NewWorkspaceStepRunnerDelegate(terraformExecutor, defaultTfVersion, runner) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this delegation is the most important fix in this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me @krrrr38 !
Let's get some more eyes on this before merging.
what
why
atlantis import
requireterraform init
process for initialize dir. At that timeterraform workspace select
is also required like plan_step_runner.Asis impl doesn't switch workspace, so not work
atlantis import
on workspace.tests
references
atlantis import
does not setterraform.workspace
#2930