github.com/kcburge/terraform@v0.11.12-beta1/moduledeps/provider.go (about)

     1  package moduledeps
     2  
     3  import (
     4  	"strings"
     5  )
     6  
     7  // ProviderInstance describes a particular provider instance by its full name,
     8  // like "null" or "aws.foo".
     9  type ProviderInstance string
    10  
    11  // Type returns the provider type of this instance. For example, for an instance
    12  // named "aws.foo" the type is "aws".
    13  func (p ProviderInstance) Type() string {
    14  	t := string(p)
    15  	if dotPos := strings.Index(t, "."); dotPos != -1 {
    16  		t = t[:dotPos]
    17  	}
    18  	return t
    19  }
    20  
    21  // Alias returns the alias of this provider, if any. An instance named "aws.foo"
    22  // has the alias "foo", while an instance named just "docker" has no alias,
    23  // so the empty string would be returned.
    24  func (p ProviderInstance) Alias() string {
    25  	t := string(p)
    26  	if dotPos := strings.Index(t, "."); dotPos != -1 {
    27  		return t[dotPos+1:]
    28  	}
    29  	return ""
    30  }