mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
command/show (-json): fix panic if a moduleCall has a nil config (#21569)
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 is an unusual edge case in the category of "probably should not happen", caused by #21568
This commit is contained in:
commit
e9e718b318
@ -238,6 +238,11 @@ func marshalModuleCalls(c *configs.Config, schemas *terraform.Schemas) map[strin
|
|||||||
}
|
}
|
||||||
|
|
||||||
func marshalModuleCall(c *configs.Config, mc *configs.ModuleCall, schemas *terraform.Schemas) moduleCall {
|
func marshalModuleCall(c *configs.Config, mc *configs.ModuleCall, schemas *terraform.Schemas) moduleCall {
|
||||||
|
// It is possible to have a module call with a nil config.
|
||||||
|
if c == nil {
|
||||||
|
return moduleCall{}
|
||||||
|
}
|
||||||
|
|
||||||
ret := moduleCall{
|
ret := moduleCall{
|
||||||
Source: mc.SourceAddr,
|
Source: mc.SourceAddr,
|
||||||
VersionConstraint: mc.Version.Required.String(),
|
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