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
func (n *NodeAbstractResource) ProvidedBy() []string {
func (n *NodeAbstractResource) ProvidedBy() string {
// If we have a config we prefer that above all else
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 n.ResourceState != nil && n.ResourceState.Provider != "" {
return []string{n.ResourceState.Provider}
return n.ResourceState.Provider
}
// Use our type
return []string{resourceProvider(n.Addr.Type, "")}
return resourceProvider(n.Addr.Type, "")
}
// GraphNodeProvisionerConsumer

View File

@ -66,8 +66,8 @@ func (n *graphNodeDeposedResource) Name() string {
return fmt.Sprintf("%s (deposed #%d)", n.ResourceName, n.Index)
}
func (n *graphNodeDeposedResource) ProvidedBy() []string {
return []string{resourceProvider(n.ResourceName, n.ProviderName)}
func (n *graphNodeDeposedResource) ProvidedBy() string {
return resourceProvider(n.ResourceName, n.ProviderName)
}
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)
}
func (n *graphNodeImportState) ProvidedBy() []string {
return []string{resourceProvider(n.Addr.Type, n.ProviderName)}
func (n *graphNodeImportState) ProvidedBy() string {
return resourceProvider(n.Addr.Type, n.ProviderName)
}
func (n *graphNodeImportState) SetProvider(p string) {

View File

@ -10,7 +10,6 @@ import (
"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 {
return GraphTransformMulti(
// Add providers from the config
@ -57,8 +56,7 @@ type GraphNodeCloseProvider interface {
// a provider must implement. ProvidedBy must return the name of the provider
// to use.
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.
SetProvider(string)
}
@ -74,7 +72,7 @@ func (t *ProviderTransformer) Transform(g *Graph) error {
m := providerVertexMap(g)
for _, v := range g.Vertices() {
if pv, ok := v.(GraphNodeProviderConsumer); ok {
p := pv.ProvidedBy()[0]
p := pv.ProvidedBy()
key := providerMapKey(p, pv)
target := m[key]
@ -187,7 +185,7 @@ func (t *MissingProviderTransformer) Transform(g *Graph) error {
continue
}
p := pv.ProvidedBy()[0]
p := pv.ProvidedBy()
key := ResolveProviderName(p, nil)
provider := m[key]
@ -357,8 +355,8 @@ func (n *graphNodeProviderConsumerDummy) Path() []string {
return n.PathValue
}
func (n *graphNodeProviderConsumerDummy) ProvidedBy() []string {
return []string{n.ProviderValue}
func (n *graphNodeProviderConsumerDummy) ProvidedBy() string {
return n.ProviderValue
}
func (n *graphNodeProviderConsumerDummy) SetProvider(string) {}