mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-28 01:41:48 -06:00
command/show (-json): fix panic if a moduleCall has a nil config
In the unlikely event that a moduleCall has a nil config - for example, if a nested module call includes a variable with a typo in an attribute - continue gracefully.
This commit is contained in:
parent
ab9e98da3c
commit
703f024cbd
@ -238,6 +238,12 @@ func marshalModuleCalls(c *configs.Config, schemas *terraform.Schemas) map[strin
|
||||
}
|
||||
|
||||
func marshalModuleCall(c *configs.Config, mc *configs.ModuleCall, schemas *terraform.Schemas) moduleCall {
|
||||
// It's possible, though unlikely, to have a module call with a nil config
|
||||
// https://github.com/hashicorp/terraform/issues/21543
|
||||
if c == nil {
|
||||
return moduleCall{}
|
||||
}
|
||||
|
||||
ret := moduleCall{
|
||||
Source: mc.SourceAddr,
|
||||
VersionConstraint: mc.Version.Required.String(),
|
||||
|
3
command/test-fixtures/show-json/nested-modules/main.tf
Normal file
3
command/test-fixtures/show-json/nested-modules/main.tf
Normal file
@ -0,0 +1,3 @@
|
||||
module "my_module" {
|
||||
source = "./modules"
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
module "more" {
|
||||
source = "./more-modules"
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
variable "misspelled" {
|
||||
default = "ehllo"
|
||||
descriptoni = "I am a misspelled attribute"
|
||||
}
|
23
command/test-fixtures/show-json/nested-modules/output.json
Normal file
23
command/test-fixtures/show-json/nested-modules/output.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"format_version": "0.1",
|
||||
"terraform_version": "0.12.1-dev",
|
||||
"planned_values": {
|
||||
"root_module": {}
|
||||
},
|
||||
"configuration": {
|
||||
"root_module": {
|
||||
"module_calls": {
|
||||
"my_module": {
|
||||
"source": "./modules",
|
||||
"module": {
|
||||
"module_calls": {
|
||||
"more": {
|
||||
"module": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user