forked from hashicorp/terraform-provider-azurerm
/
redis_enterprise_cluster_location.go
64 lines (54 loc) · 1.64 KB
/
redis_enterprise_cluster_location.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package validate
import (
"fmt"
"github.com/kevinklinger/terraform-provider-azurerm/v2/helpers/azure"
"github.com/kevinklinger/terraform-provider-azurerm/v2/internal/location"
)
// RedisEnterpriseClusterLocation - validates that the passed interface contains a valid Redis Enterprist Cluster location or not
func RedisEnterpriseClusterLocation(input interface{}, key string) (warnings []string, errors []error) {
v, ok := input.(string)
if !ok {
errors = append(errors, fmt.Errorf("expected %q to be a string", key))
return warnings, errors
}
location := location.Normalize(v)
validLocations := validRedisEnterpriseClusterLocations()
for _, str := range validLocations {
if location == str {
return warnings, errors
}
}
errors = append(errors, fmt.Errorf("%q does not currently support Redis Enterprise Clusters. Locations which currently support Redis Enterprise Clusters are [%s]", v, azure.QuotedStringSlice(friendlyValidRedisEnterpriseClusterLocations())))
return warnings, errors
}
func validRedisEnterpriseClusterLocations() []string {
var validLoc []string
for _, v := range friendlyValidRedisEnterpriseClusterLocations() {
validLoc = append(validLoc, location.Normalize(v))
}
return validLoc
}
func friendlyValidRedisEnterpriseClusterLocations() []string {
return []string{
"Australia East",
"Australia Southeast",
"Brazil South",
"Canada Central",
"Central India",
"Central US",
"Central US EUAP",
"East Asia",
"East US",
"North Europe",
"South Central US",
"South India",
"Southeast Asia",
"UK South",
"UK West",
"East US 2",
"East US 2 EUAP",
"West Europe",
"West US",
"West US 2",
}
}