change ProviderConfig.Scope to Path
Though it's intended for "interpolation scope", Path is generally used for this elsewhere.
This commit is contained in:
parent
f08bf76ef2
commit
2e505083cd
|
@ -70,10 +70,10 @@ type ProviderConfig struct {
|
|||
Version string
|
||||
RawConfig *RawConfig
|
||||
|
||||
// Scope records where the Provider was declared in a module tree, so that
|
||||
// it can be copied into child module providers yes still interpolated in
|
||||
// Path records where the Provider was declared in a module tree, so that
|
||||
// it can be copied into child module providers yet still interpolated in
|
||||
// the correct scope.
|
||||
Scope []string
|
||||
Path []string
|
||||
}
|
||||
|
||||
// A resource represents a single Terraform resource in the configuration.
|
||||
|
|
|
@ -364,8 +364,8 @@ func (t *Tree) inheritProviderConfigs(stack []*Tree) {
|
|||
continue
|
||||
}
|
||||
|
||||
pc.Scope = pt.Path()
|
||||
pc.Scope = append([]string{RootName}, pt.path...)
|
||||
pc.Path = pt.Path()
|
||||
pc.Path = append([]string{RootName}, pt.path...)
|
||||
pc.RawConfig = parentProvider.RawConfig
|
||||
log.Printf("[TRACE] provider %q inheriting config from %q",
|
||||
strings.Join(append(t.Path(), pc.FullName()), "."),
|
||||
|
@ -430,7 +430,7 @@ func (t *Tree) inheritProviderConfigs(stack []*Tree) {
|
|||
|
||||
// Copy it in, but set an interpolation Scope.
|
||||
// An interpolation Scope always need to have "root"
|
||||
pc.Scope = append([]string{RootName}, parent.path...)
|
||||
pc.Path = append([]string{RootName}, parent.path...)
|
||||
pc.RawConfig = parentProvider.RawConfig
|
||||
log.Printf("[TRACE] provider %q inheriting config from %q",
|
||||
strings.Join(append(t.Path(), pc.FullName()), "."),
|
||||
|
|
|
@ -566,8 +566,8 @@ func TestTreeProviders_basic(t *testing.T) {
|
|||
)
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(aTop.Scope, []string{RootName}) {
|
||||
log.Fatalf(`expected scope for "top": {"root"}, got %#v`, aTop.Scope)
|
||||
if !reflect.DeepEqual(aTop.Path, []string{RootName}) {
|
||||
log.Fatalf(`expected scope for "top": {"root"}, got %#v`, aTop.Path)
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(bBottom.RawConfig.RawMap(), bottomRaw.RawConfig.RawMap()) {
|
||||
|
@ -576,8 +576,8 @@ func TestTreeProviders_basic(t *testing.T) {
|
|||
bBottom.RawConfig.RawMap(),
|
||||
)
|
||||
}
|
||||
if !reflect.DeepEqual(bBottom.Scope, []string{RootName, "a"}) {
|
||||
t.Fatalf(`expected scope for "bottom": {"root", "a"}, got %#v`, bBottom.Scope)
|
||||
if !reflect.DeepEqual(bBottom.Path, []string{RootName, "a"}) {
|
||||
t.Fatalf(`expected scope for "bottom": {"root", "a"}, got %#v`, bBottom.Path)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -608,8 +608,8 @@ func TestTreeProviders_implicit(t *testing.T) {
|
|||
t.Fatal("could not find provider 'foo' in child module")
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual([]string{RootName}, foo.Scope) {
|
||||
t.Fatalf(`expected foo scope of {"root"}, got %#v`, foo.Scope)
|
||||
if !reflect.DeepEqual([]string{RootName}, foo.Path) {
|
||||
t.Fatalf(`expected foo scope of {"root"}, got %#v`, foo.Path)
|
||||
}
|
||||
|
||||
expected := map[string]interface{}{
|
||||
|
@ -657,8 +657,8 @@ func TestTreeProviders_implicitMultiLevel(t *testing.T) {
|
|||
t.Fatal("could not find provider 'foo' in child module")
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual([]string{RootName}, foo.Scope) {
|
||||
t.Fatalf(`expected foo scope of {"root"}, got %#v`, foo.Scope)
|
||||
if !reflect.DeepEqual([]string{RootName}, foo.Path) {
|
||||
t.Fatalf(`expected foo scope of {"root"}, got %#v`, foo.Path)
|
||||
}
|
||||
|
||||
expected := map[string]interface{}{
|
||||
|
@ -677,8 +677,8 @@ func TestTreeProviders_implicitMultiLevel(t *testing.T) {
|
|||
t.Fatal("could not find provider 'bar' in grandchild module")
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual([]string{RootName, "child"}, bar.Scope) {
|
||||
t.Fatalf(`expected bar scope of {"root", "child"}, got %#v`, bar.Scope)
|
||||
if !reflect.DeepEqual([]string{RootName, "child"}, bar.Path) {
|
||||
t.Fatalf(`expected bar scope of {"root", "child"}, got %#v`, bar.Path)
|
||||
}
|
||||
|
||||
expected = map[string]interface{}{
|
||||
|
|
|
@ -277,7 +277,7 @@ func (ctx *BuiltinEvalContext) InterpolateProvider(
|
|||
var cfg *config.RawConfig
|
||||
|
||||
if pc != nil && pc.RawConfig != nil {
|
||||
path := pc.Scope
|
||||
path := pc.Path
|
||||
if len(path) == 0 {
|
||||
path = ctx.Path()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue