ProvidedBy return value is a single string
Clean up ProvidedBy, which doesn't need to be a slice.
This commit is contained in:
parent
ed0d57d1b7
commit
72d4e15c47
|
@ -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
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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) {}
|
||||
|
|
Loading…
Reference in New Issue