mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
command: "terraform output" mustn't panic when no state is present
This is verified by TestOutput_noArgs.
This commit is contained in:
parent
53b5b95ef5
commit
37bc187f95
@ -13,6 +13,7 @@ import (
|
||||
"github.com/hashicorp/terraform/addrs"
|
||||
"github.com/hashicorp/terraform/config/hcl2shim"
|
||||
"github.com/hashicorp/terraform/repl"
|
||||
"github.com/hashicorp/terraform/states"
|
||||
"github.com/hashicorp/terraform/tfdiags"
|
||||
)
|
||||
|
||||
@ -95,6 +96,10 @@ func (c *OutputCommand) Run(args []string) int {
|
||||
}
|
||||
|
||||
state := stateStore.State()
|
||||
if state == nil {
|
||||
state = states.NewState()
|
||||
}
|
||||
|
||||
mod := state.Module(moduleAddr)
|
||||
if mod == nil {
|
||||
c.Ui.Error(fmt.Sprintf(
|
||||
|
Loading…
Reference in New Issue
Block a user