terraform: fix issue merging provider version constraints
A bug in ConfigTreeDependencies, where a pointer was being updated instead of the map value, meant that only the first provider config version constraing to be processes was being stored. This fixes that bug, so now the returned moduledeps.Providers could have multiple version constraints. The responsibility for resolving provider version selection continues to lie in the command package's ProviderResolver (under plugins.go).
This commit is contained in:
parent
c242f9389d
commit
b4f21b6044
|
@ -94,7 +94,11 @@ func configTreeConfigDependencies(root *configs.Config, inheritProviders map[str
|
|||
discoConstraints = discovery.NewConstraints(pCfg.Version.Required)
|
||||
}
|
||||
if existing, exists := providers[fqn]; exists {
|
||||
existing.Constraints = existing.Constraints.Append(discoConstraints)
|
||||
constraints := existing.Constraints.Append(discoConstraints)
|
||||
providers[fqn] = moduledeps.ProviderDependency{
|
||||
Constraints: constraints,
|
||||
Reason: moduledeps.ProviderDependencyExplicit,
|
||||
}
|
||||
} else {
|
||||
providers[fqn] = moduledeps.ProviderDependency{
|
||||
Constraints: discoConstraints,
|
||||
|
|
|
@ -42,7 +42,7 @@ func TestModuleTreeDependencies(t *testing.T) {
|
|||
Name: "root",
|
||||
Providers: moduledeps.Providers{
|
||||
addrs.NewLegacyProvider("foo"): moduledeps.ProviderDependency{
|
||||
Constraints: discovery.ConstraintStr(">=1.0.0").MustParse(),
|
||||
Constraints: discovery.ConstraintStr(">=1.0.0,>=2.0.0").MustParse(),
|
||||
Reason: moduledeps.ProviderDependencyExplicit,
|
||||
},
|
||||
},
|
||||
|
@ -213,9 +213,10 @@ func TestModuleTreeDependencies(t *testing.T) {
|
|||
Name: "root",
|
||||
Providers: moduledeps.Providers{
|
||||
addrs.NewLegacyProvider("foo"): moduledeps.ProviderDependency{
|
||||
Constraints: discovery.ConstraintStr(">=1.0.0").MustParse(),
|
||||
Constraints: discovery.ConstraintStr(">=1.0.0,>=2.0.0").MustParse(),
|
||||
Reason: moduledeps.ProviderDependencyExplicit,
|
||||
},
|
||||
|
||||
addrs.NewLegacyProvider("baz"): moduledeps.ProviderDependency{
|
||||
Constraints: discovery.AllVersions,
|
||||
Reason: moduledeps.ProviderDependencyFromState,
|
||||
|
|
Loading…
Reference in New Issue