forked from kubernetes/kops
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cloud.go
92 lines (74 loc) · 2.63 KB
/
cloud.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
package fi
import "k8s.io/kubernetes/federation/pkg/dnsprovider"
type CloudProviderID string
const CloudProviderAWS CloudProviderID = "aws"
const CloudProviderGCE CloudProviderID = "gce"
type Cloud interface {
ProviderID() CloudProviderID
FindDNSHostedZone(dnsName string) (string, error)
DNS() (dnsprovider.Interface, error)
}
// zonesToCloud allows us to infer from certain well-known zones to a cloud
// Note it is safe to "overmap" zones that don't exist: we'll check later if the zones actually exist
var zonesToCloud = map[string]CloudProviderID{
"us-east-1a": CloudProviderAWS,
"us-east-1b": CloudProviderAWS,
"us-east-1c": CloudProviderAWS,
"us-east-1d": CloudProviderAWS,
"us-east-1e": CloudProviderAWS,
"us-west-1a": CloudProviderAWS,
"us-west-1b": CloudProviderAWS,
"us-west-1c": CloudProviderAWS,
"us-west-1d": CloudProviderAWS,
"us-west-1e": CloudProviderAWS,
"us-west-2a": CloudProviderAWS,
"us-west-2b": CloudProviderAWS,
"us-west-2c": CloudProviderAWS,
"us-west-2d": CloudProviderAWS,
"us-west-2e": CloudProviderAWS,
"eu-west-1a": CloudProviderAWS,
"eu-west-1b": CloudProviderAWS,
"eu-west-1c": CloudProviderAWS,
"eu-west-1d": CloudProviderAWS,
"eu-west-1e": CloudProviderAWS,
"eu-central-1a": CloudProviderAWS,
"eu-central-1b": CloudProviderAWS,
"eu-central-1c": CloudProviderAWS,
"eu-central-1d": CloudProviderAWS,
"eu-central-1e": CloudProviderAWS,
"ap-south-1a": CloudProviderAWS,
"ap-south-1b": CloudProviderAWS,
"ap-south-1c": CloudProviderAWS,
"ap-south-1d": CloudProviderAWS,
"ap-south-1e": CloudProviderAWS,
"ap-southeast-1a": CloudProviderAWS,
"ap-southeast-1b": CloudProviderAWS,
"ap-southeast-1c": CloudProviderAWS,
"ap-southeast-1d": CloudProviderAWS,
"ap-southeast-1e": CloudProviderAWS,
"ap-southeast-2a": CloudProviderAWS,
"ap-southeast-2b": CloudProviderAWS,
"ap-southeast-2c": CloudProviderAWS,
"ap-southeast-2d": CloudProviderAWS,
"ap-southeast-2e": CloudProviderAWS,
"ap-northeast-1a": CloudProviderAWS,
"ap-northeast-1b": CloudProviderAWS,
"ap-northeast-1c": CloudProviderAWS,
"ap-northeast-1d": CloudProviderAWS,
"ap-northeast-1e": CloudProviderAWS,
"ap-northeast-2a": CloudProviderAWS,
"ap-northeast-2b": CloudProviderAWS,
"ap-northeast-2c": CloudProviderAWS,
"ap-northeast-2d": CloudProviderAWS,
"ap-northeast-2e": CloudProviderAWS,
"sa-east-1a": CloudProviderAWS,
"sa-east-1b": CloudProviderAWS,
"sa-east-1c": CloudProviderAWS,
"sa-east-1d": CloudProviderAWS,
"sa-east-1e": CloudProviderAWS,
}
// GuessCloudForZone tries to infer the cloudprovider from the zone name
func GuessCloudForZone(zone string) (CloudProviderID, bool) {
c, found := zonesToCloud[zone]
return c, found
}