change ProviderConfig.Scope to Path

Though it's intended for "interpolation scope", Path is generally used
for this elsewhere.
This commit is contained in:
James Bardin 2017-10-17 18:44:04 -04:00
parent f08bf76ef2
commit 2e505083cd
4 changed files with 17 additions and 17 deletions

View File

@ -70,10 +70,10 @@ type ProviderConfig struct {
Version string Version string
RawConfig *RawConfig RawConfig *RawConfig
// Scope records where the Provider was declared in a module tree, so that // Path records where the Provider was declared in a module tree, so that
// it can be copied into child module providers yes still interpolated in // it can be copied into child module providers yet still interpolated in
// the correct scope. // the correct scope.
Scope []string Path []string
} }
// A resource represents a single Terraform resource in the configuration. // A resource represents a single Terraform resource in the configuration.

View File

@ -364,8 +364,8 @@ func (t *Tree) inheritProviderConfigs(stack []*Tree) {
continue continue
} }
pc.Scope = pt.Path() pc.Path = pt.Path()
pc.Scope = append([]string{RootName}, pt.path...) pc.Path = append([]string{RootName}, pt.path...)
pc.RawConfig = parentProvider.RawConfig pc.RawConfig = parentProvider.RawConfig
log.Printf("[TRACE] provider %q inheriting config from %q", log.Printf("[TRACE] provider %q inheriting config from %q",
strings.Join(append(t.Path(), pc.FullName()), "."), 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. // Copy it in, but set an interpolation Scope.
// An interpolation Scope always need to have "root" // 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 pc.RawConfig = parentProvider.RawConfig
log.Printf("[TRACE] provider %q inheriting config from %q", log.Printf("[TRACE] provider %q inheriting config from %q",
strings.Join(append(t.Path(), pc.FullName()), "."), strings.Join(append(t.Path(), pc.FullName()), "."),

View File

@ -566,8 +566,8 @@ func TestTreeProviders_basic(t *testing.T) {
) )
} }
if !reflect.DeepEqual(aTop.Scope, []string{RootName}) { if !reflect.DeepEqual(aTop.Path, []string{RootName}) {
log.Fatalf(`expected scope for "top": {"root"}, got %#v`, aTop.Scope) log.Fatalf(`expected scope for "top": {"root"}, got %#v`, aTop.Path)
} }
if !reflect.DeepEqual(bBottom.RawConfig.RawMap(), bottomRaw.RawConfig.RawMap()) { if !reflect.DeepEqual(bBottom.RawConfig.RawMap(), bottomRaw.RawConfig.RawMap()) {
@ -576,8 +576,8 @@ func TestTreeProviders_basic(t *testing.T) {
bBottom.RawConfig.RawMap(), bBottom.RawConfig.RawMap(),
) )
} }
if !reflect.DeepEqual(bBottom.Scope, []string{RootName, "a"}) { if !reflect.DeepEqual(bBottom.Path, []string{RootName, "a"}) {
t.Fatalf(`expected scope for "bottom": {"root", "a"}, got %#v`, bBottom.Scope) 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") t.Fatal("could not find provider 'foo' in child module")
} }
if !reflect.DeepEqual([]string{RootName}, foo.Scope) { if !reflect.DeepEqual([]string{RootName}, foo.Path) {
t.Fatalf(`expected foo scope of {"root"}, got %#v`, foo.Scope) t.Fatalf(`expected foo scope of {"root"}, got %#v`, foo.Path)
} }
expected := map[string]interface{}{ expected := map[string]interface{}{
@ -657,8 +657,8 @@ func TestTreeProviders_implicitMultiLevel(t *testing.T) {
t.Fatal("could not find provider 'foo' in child module") t.Fatal("could not find provider 'foo' in child module")
} }
if !reflect.DeepEqual([]string{RootName}, foo.Scope) { if !reflect.DeepEqual([]string{RootName}, foo.Path) {
t.Fatalf(`expected foo scope of {"root"}, got %#v`, foo.Scope) t.Fatalf(`expected foo scope of {"root"}, got %#v`, foo.Path)
} }
expected := map[string]interface{}{ expected := map[string]interface{}{
@ -677,8 +677,8 @@ func TestTreeProviders_implicitMultiLevel(t *testing.T) {
t.Fatal("could not find provider 'bar' in grandchild module") t.Fatal("could not find provider 'bar' in grandchild module")
} }
if !reflect.DeepEqual([]string{RootName, "child"}, bar.Scope) { if !reflect.DeepEqual([]string{RootName, "child"}, bar.Path) {
t.Fatalf(`expected bar scope of {"root", "child"}, got %#v`, bar.Scope) t.Fatalf(`expected bar scope of {"root", "child"}, got %#v`, bar.Path)
} }
expected = map[string]interface{}{ expected = map[string]interface{}{

View File

@ -277,7 +277,7 @@ func (ctx *BuiltinEvalContext) InterpolateProvider(
var cfg *config.RawConfig var cfg *config.RawConfig
if pc != nil && pc.RawConfig != nil { if pc != nil && pc.RawConfig != nil {
path := pc.Scope path := pc.Path
if len(path) == 0 { if len(path) == 0 {
path = ctx.Path() path = ctx.Path()
} }