mirror of
https://github.com/hashicorp/terraform.git
synced 2026-05-28 04:03:27 -04:00
refactor: Replace use of ModulePath with c.WorkingDir.RootModuleDir() to separate concerns
This commit is contained in:
parent
f61324a3e3
commit
b32b60f6a7
2 changed files with 5 additions and 10 deletions
|
|
@ -21,6 +21,7 @@ import (
|
|||
"github.com/hashicorp/terraform/internal/backend/remote-state/inmem"
|
||||
"github.com/hashicorp/terraform/internal/command/arguments"
|
||||
"github.com/hashicorp/terraform/internal/command/views"
|
||||
"github.com/hashicorp/terraform/internal/command/workdir"
|
||||
"github.com/hashicorp/terraform/internal/providers"
|
||||
"github.com/hashicorp/terraform/internal/states"
|
||||
"github.com/hashicorp/terraform/internal/states/statefile"
|
||||
|
|
@ -1249,6 +1250,7 @@ func TestWorkspace_list_jsonOutput(t *testing.T) {
|
|||
addrs.NewDefaultProvider("test"): providers.FactoryFixed(mock),
|
||||
},
|
||||
},
|
||||
WorkingDir: workdir.NewDir("."),
|
||||
}
|
||||
|
||||
// All commands run in this test should receive the -json flag
|
||||
|
|
@ -1259,7 +1261,7 @@ func TestWorkspace_list_jsonOutput(t *testing.T) {
|
|||
Meta: meta,
|
||||
}
|
||||
if code := listCmd.Run(args); code != 0 {
|
||||
t.Fatalf("bad: %d\n\n%s", code, done(t).Stderr())
|
||||
t.Fatalf("bad: %d\n\nstderr: %s\n\nstdout: %s", code, done(t).Stderr(), done(t).Stdout())
|
||||
}
|
||||
output := done(t)
|
||||
expectedStdOut := `{
|
||||
|
|
@ -1314,7 +1316,7 @@ func TestWorkspace_list_jsonOutput(t *testing.T) {
|
|||
Meta: meta,
|
||||
}
|
||||
if code := listCmd.Run(args); code != 0 {
|
||||
t.Fatalf("bad: %d\n\n%s", code, done(t).Stderr())
|
||||
t.Fatalf("bad: %d\n\nstderr: %s\n\nstdout: %s", code, done(t).Stderr(), done(t).Stdout())
|
||||
}
|
||||
output = done(t)
|
||||
expectedStdOut = `{
|
||||
|
|
|
|||
|
|
@ -50,15 +50,8 @@ func (c *WorkspaceListCommand) Run(rawArgs []string) int {
|
|||
envCommandShowWarning(c.Ui, c.LegacyName)
|
||||
}
|
||||
|
||||
// Get the config path. Any unexpected CLI arguments have already been detected by arguments.ParseWorkspace, so we pass nil here.
|
||||
configPath, err := ModulePath(nil)
|
||||
if err != nil {
|
||||
diags.Append(err)
|
||||
view.List("", nil, diags)
|
||||
return 1
|
||||
}
|
||||
|
||||
// Load the backend
|
||||
configPath := c.WorkingDir.RootModuleDir()
|
||||
b, diags := c.backend(configPath, args.ViewType)
|
||||
if diags.HasErrors() {
|
||||
view.List("", nil, diags)
|
||||
|
|
|
|||
Loading…
Reference in a new issue