1package moduledeps 2 3import ( 4 "strings" 5) 6 7// ProviderInstance describes a particular provider instance by its full name, 8// like "null" or "aws.foo". 9type 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". 13func (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. 24func (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} 31