mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-09-07 01:26:43 +00:00
![Riley Karson](/assets/img/avatar_default.png)
```bash GO111MODULE=on go get github.com/hashicorp/terraform@pluginsdk-v0.12-early7 GO111MODULE=on go mod vendor GO111MODULE=on go mod tidy ```
48 lines
1.1 KiB
Go
48 lines
1.1 KiB
Go
package providers
|
|
|
|
import (
|
|
"sort"
|
|
|
|
"github.com/hashicorp/terraform/addrs"
|
|
)
|
|
|
|
// AddressedTypes is a helper that extracts all of the distinct provider
|
|
// types from the given list of relative provider configuration addresses.
|
|
func AddressedTypes(providerAddrs []addrs.ProviderConfig) []string {
|
|
if len(providerAddrs) == 0 {
|
|
return nil
|
|
}
|
|
m := map[string]struct{}{}
|
|
for _, addr := range providerAddrs {
|
|
m[addr.Type] = struct{}{}
|
|
}
|
|
|
|
names := make([]string, 0, len(m))
|
|
for typeName := range m {
|
|
names = append(names, typeName)
|
|
}
|
|
|
|
sort.Strings(names) // Stable result for tests
|
|
return names
|
|
}
|
|
|
|
// AddressedTypesAbs is a helper that extracts all of the distinct provider
|
|
// types from the given list of absolute provider configuration addresses.
|
|
func AddressedTypesAbs(providerAddrs []addrs.AbsProviderConfig) []string {
|
|
if len(providerAddrs) == 0 {
|
|
return nil
|
|
}
|
|
m := map[string]struct{}{}
|
|
for _, addr := range providerAddrs {
|
|
m[addr.ProviderConfig.Type] = struct{}{}
|
|
}
|
|
|
|
names := make([]string, 0, len(m))
|
|
for typeName := range m {
|
|
names = append(names, typeName)
|
|
}
|
|
|
|
sort.Strings(names) // Stable result for tests
|
|
return names
|
|
}
|