jsonconfig: add implicitly created provider configs
This commit is contained in:
parent
0ce040405c
commit
3c32f7a56c
|
@ -239,27 +239,29 @@ func marshalProviderConfigs(
|
|||
m[key] = p
|
||||
}
|
||||
|
||||
// In child modules, providers defined in the parent module can be implicitly used.
|
||||
// Such providers could have no requirements and configuration blocks defined.
|
||||
if c.Parent != nil {
|
||||
for req := range reqs {
|
||||
// Implicit inheritance only applies to the default provider,
|
||||
// so the provider name must be same as the provider type.
|
||||
key := opaqueProviderKey(req.Type, c.Path.String())
|
||||
if _, exists := m[key]; exists {
|
||||
continue
|
||||
}
|
||||
|
||||
parentKey := opaqueProviderKey(req.Type, c.Parent.Path.String())
|
||||
p := providerConfig{
|
||||
Name: req.Type,
|
||||
FullName: req.String(),
|
||||
ModuleAddress: c.Path.String(),
|
||||
parentKey: findSourceProviderKey(parentKey, req.String(), m),
|
||||
}
|
||||
|
||||
m[key] = p
|
||||
// Providers could be implicitly created or inherited from the parent module
|
||||
// when no requirements and configuration block defined.
|
||||
for req := range reqs {
|
||||
// Only default providers could implicitly exist,
|
||||
// so the provider name must be same as the provider type.
|
||||
key := opaqueProviderKey(req.Type, c.Path.String())
|
||||
if _, exists := m[key]; exists {
|
||||
continue
|
||||
}
|
||||
|
||||
p := providerConfig{
|
||||
Name: req.Type,
|
||||
FullName: req.String(),
|
||||
ModuleAddress: c.Path.String(),
|
||||
}
|
||||
|
||||
// In child modules, providers defined in the parent module can be implicitly used.
|
||||
if c.Parent != nil {
|
||||
parentKey := opaqueProviderKey(req.Type, c.Parent.Path.String())
|
||||
p.parentKey = findSourceProviderKey(parentKey, p.FullName, m)
|
||||
}
|
||||
|
||||
m[key] = p
|
||||
}
|
||||
|
||||
// Must also visit our child modules, recursively.
|
||||
|
|
|
@ -130,6 +130,12 @@
|
|||
}
|
||||
},
|
||||
"configuration": {
|
||||
"provider_config": {
|
||||
"test": {
|
||||
"name": "test",
|
||||
"full_name": "registry.terraform.io/hashicorp/test"
|
||||
}
|
||||
},
|
||||
"root_module": {
|
||||
"outputs": {
|
||||
"test": {
|
||||
|
|
|
@ -96,6 +96,12 @@
|
|||
}
|
||||
},
|
||||
"configuration": {
|
||||
"provider_config": {
|
||||
"test": {
|
||||
"name": "test",
|
||||
"full_name": "registry.terraform.io/hashicorp/test"
|
||||
}
|
||||
},
|
||||
"root_module": {
|
||||
"outputs": {
|
||||
"test": {
|
||||
|
|
|
@ -141,6 +141,12 @@
|
|||
}
|
||||
},
|
||||
"configuration": {
|
||||
"provider_config": {
|
||||
"test": {
|
||||
"name": "test",
|
||||
"full_name": "registry.terraform.io/hashicorp/test"
|
||||
}
|
||||
},
|
||||
"root_module": {
|
||||
"resources": [
|
||||
{
|
||||
|
|
|
@ -43,6 +43,12 @@
|
|||
}
|
||||
],
|
||||
"configuration": {
|
||||
"provider_config": {
|
||||
"test": {
|
||||
"name": "test",
|
||||
"full_name": "registry.terraform.io/hashicorp/test"
|
||||
}
|
||||
},
|
||||
"root_module": {
|
||||
"resources": [
|
||||
{
|
||||
|
|
|
@ -293,6 +293,11 @@
|
|||
"module_address": "module.module_test_foo",
|
||||
"name": "test",
|
||||
"full_name": "registry.terraform.io/hashicorp/test"
|
||||
},
|
||||
"module.module_test_bar:test": {
|
||||
"module_address": "module.module_test_bar",
|
||||
"name": "test",
|
||||
"full_name": "registry.terraform.io/hashicorp/test"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -143,6 +143,12 @@
|
|||
}
|
||||
},
|
||||
"configuration": {
|
||||
"provider_config": {
|
||||
"test": {
|
||||
"name": "test",
|
||||
"full_name": "registry.terraform.io/hashicorp/test"
|
||||
}
|
||||
},
|
||||
"root_module": {
|
||||
"resources": [
|
||||
{
|
||||
|
|
|
@ -68,6 +68,12 @@
|
|||
}
|
||||
},
|
||||
"configuration": {
|
||||
"provider_config": {
|
||||
"test": {
|
||||
"name": "test",
|
||||
"full_name": "registry.terraform.io/hashicorp/test"
|
||||
}
|
||||
},
|
||||
"root_module": {
|
||||
"resources": [
|
||||
{
|
||||
|
|
|
@ -137,6 +137,12 @@
|
|||
}
|
||||
},
|
||||
"configuration": {
|
||||
"provider_config": {
|
||||
"test": {
|
||||
"name": "test",
|
||||
"full_name": "registry.terraform.io/hashicorp/test"
|
||||
}
|
||||
},
|
||||
"root_module": {
|
||||
"outputs": {
|
||||
"test": {
|
||||
|
|
|
@ -37,9 +37,7 @@
|
|||
"name": "test",
|
||||
"provider_name": "registry.terraform.io/hashicorp/test",
|
||||
"change": {
|
||||
"actions": [
|
||||
"create"
|
||||
],
|
||||
"actions": ["create"],
|
||||
"before": null,
|
||||
"after": {
|
||||
"ami": "bar-var"
|
||||
|
@ -53,6 +51,13 @@
|
|||
}
|
||||
],
|
||||
"configuration": {
|
||||
"provider_config": {
|
||||
"module.my_module.module.more:test": {
|
||||
"module_address": "module.my_module.module.more",
|
||||
"name": "test",
|
||||
"full_name": "registry.terraform.io/hashicorp/test"
|
||||
}
|
||||
},
|
||||
"root_module": {
|
||||
"module_calls": {
|
||||
"my_module": {
|
||||
|
@ -71,9 +76,7 @@
|
|||
"provider_config_key": "module.my_module.module.more:test",
|
||||
"expressions": {
|
||||
"ami": {
|
||||
"references": [
|
||||
"var.test_var"
|
||||
]
|
||||
"references": ["var.test_var"]
|
||||
}
|
||||
},
|
||||
"schema_version": 0
|
||||
|
|
|
@ -70,6 +70,12 @@
|
|||
}
|
||||
},
|
||||
"configuration": {
|
||||
"provider_config": {
|
||||
"test": {
|
||||
"name": "test",
|
||||
"full_name": "registry.terraform.io/hashicorp/test"
|
||||
}
|
||||
},
|
||||
"root_module": {
|
||||
"resources": [
|
||||
{
|
||||
|
|
|
@ -81,6 +81,12 @@
|
|||
}
|
||||
},
|
||||
"configuration": {
|
||||
"provider_config": {
|
||||
"test": {
|
||||
"name": "test",
|
||||
"full_name": "registry.terraform.io/hashicorp/test"
|
||||
}
|
||||
},
|
||||
"root_module": {
|
||||
"outputs": {
|
||||
"test": {
|
||||
|
|
Loading…
Reference in New Issue