Merge pull request #16573 from hashicorp/jbardin/ProvidedBy

Minor cleanup, ProvidedBy return value is a single string
This commit is contained in:
James Bardin 2017-11-06 15:03:12 -05:00 committed by GitHub
commit a089a4ba21
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 15 deletions

View File

@ -178,19 +178,19 @@ func (n *NodeAbstractResource) SetProvider(p string) {
} }
// GraphNodeProviderConsumer // GraphNodeProviderConsumer
func (n *NodeAbstractResource) ProvidedBy() []string { func (n *NodeAbstractResource) ProvidedBy() string {
// If we have a config we prefer that above all else // If we have a config we prefer that above all else
if n.Config != nil { if n.Config != nil {
return []string{resourceProvider(n.Config.Type, n.Config.Provider)} return resourceProvider(n.Config.Type, n.Config.Provider)
} }
// If we have state, then we will use the provider from there // If we have state, then we will use the provider from there
if n.ResourceState != nil && n.ResourceState.Provider != "" { if n.ResourceState != nil && n.ResourceState.Provider != "" {
return []string{n.ResourceState.Provider} return n.ResourceState.Provider
} }
// Use our type // Use our type
return []string{resourceProvider(n.Addr.Type, "")} return resourceProvider(n.Addr.Type, "")
} }
// GraphNodeProvisionerConsumer // GraphNodeProvisionerConsumer

View File

@ -66,8 +66,8 @@ func (n *graphNodeDeposedResource) Name() string {
return fmt.Sprintf("%s (deposed #%d)", n.ResourceName, n.Index) return fmt.Sprintf("%s (deposed #%d)", n.ResourceName, n.Index)
} }
func (n *graphNodeDeposedResource) ProvidedBy() []string { func (n *graphNodeDeposedResource) ProvidedBy() string {
return []string{resourceProvider(n.ResourceName, n.ProviderName)} return resourceProvider(n.ResourceName, n.ProviderName)
} }
func (n *graphNodeDeposedResource) SetProvider(p string) { func (n *graphNodeDeposedResource) SetProvider(p string) {

View File

@ -48,8 +48,8 @@ func (n *graphNodeImportState) Name() string {
return fmt.Sprintf("%s (import id: %s)", n.Addr, n.ID) return fmt.Sprintf("%s (import id: %s)", n.Addr, n.ID)
} }
func (n *graphNodeImportState) ProvidedBy() []string { func (n *graphNodeImportState) ProvidedBy() string {
return []string{resourceProvider(n.Addr.Type, n.ProviderName)} return resourceProvider(n.Addr.Type, n.ProviderName)
} }
func (n *graphNodeImportState) SetProvider(p string) { func (n *graphNodeImportState) SetProvider(p string) {

View File

@ -10,7 +10,6 @@ import (
"github.com/hashicorp/terraform/dag" "github.com/hashicorp/terraform/dag"
) )
// TODO: return the transformers and append them to the list, so we don't lose the log steps
func TransformProviders(providers []string, concrete ConcreteProviderNodeFunc, mod *module.Tree) GraphTransformer { func TransformProviders(providers []string, concrete ConcreteProviderNodeFunc, mod *module.Tree) GraphTransformer {
return GraphTransformMulti( return GraphTransformMulti(
// Add providers from the config // Add providers from the config
@ -57,8 +56,7 @@ type GraphNodeCloseProvider interface {
// a provider must implement. ProvidedBy must return the name of the provider // a provider must implement. ProvidedBy must return the name of the provider
// to use. // to use.
type GraphNodeProviderConsumer interface { type GraphNodeProviderConsumer interface {
// TODO: make this return s string instead of a []string ProvidedBy() string
ProvidedBy() []string
// Set the resolved provider address for this resource. // Set the resolved provider address for this resource.
SetProvider(string) SetProvider(string)
} }
@ -74,7 +72,7 @@ func (t *ProviderTransformer) Transform(g *Graph) error {
m := providerVertexMap(g) m := providerVertexMap(g)
for _, v := range g.Vertices() { for _, v := range g.Vertices() {
if pv, ok := v.(GraphNodeProviderConsumer); ok { if pv, ok := v.(GraphNodeProviderConsumer); ok {
p := pv.ProvidedBy()[0] p := pv.ProvidedBy()
key := providerMapKey(p, pv) key := providerMapKey(p, pv)
target := m[key] target := m[key]
@ -187,7 +185,7 @@ func (t *MissingProviderTransformer) Transform(g *Graph) error {
continue continue
} }
p := pv.ProvidedBy()[0] p := pv.ProvidedBy()
key := ResolveProviderName(p, nil) key := ResolveProviderName(p, nil)
provider := m[key] provider := m[key]
@ -357,8 +355,8 @@ func (n *graphNodeProviderConsumerDummy) Path() []string {
return n.PathValue return n.PathValue
} }
func (n *graphNodeProviderConsumerDummy) ProvidedBy() []string { func (n *graphNodeProviderConsumerDummy) ProvidedBy() string {
return []string{n.ProviderValue} return n.ProviderValue
} }
func (n *graphNodeProviderConsumerDummy) SetProvider(string) {} func (n *graphNodeProviderConsumerDummy) SetProvider(string) {}