-
Notifications
You must be signed in to change notification settings - Fork 16
/
region.go
72 lines (64 loc) · 1.36 KB
/
region.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
package region
// Region represents the sauce labs region.
type Region uint
const (
// None is an undefined sauce labs region.
None Region = iota
// USWest1 is a sauce labs region in the US, aka us-west-1.
USWest1
// EUCentral1 is a sauce labs region in the EU, aka eu-central-1.
EUCentral1
// Staging is a sauce labs internal pre-production environment.
Staging
)
var meta = []struct {
Name string
APIBaseURL string
AppBaseURL string
}{
// None
{
"",
"",
"",
},
// USWest1
{
"us-west-1",
"https://api.us-west-1.saucelabs.com",
"https://app.saucelabs.com",
},
// EUCentral1
{
"eu-central-1",
"https://api.eu-central-1.saucelabs.com",
"https://app.eu-central-1.saucelabs.com",
},
// Staging
{
"staging",
"https://api.staging.saucelabs.net",
"https://app.staging.saucelabs.net",
},
}
func (r Region) String() string {
return meta[r].Name
}
// FromString converts the given string to the corresponding Region.
// Returns None if the string did not match any Region.
func FromString(s string) Region {
for i, m := range meta {
if m.Name == s {
return Region(i)
}
}
return None
}
// APIBaseURL returns the API base URL for the region.
func (r Region) APIBaseURL() string {
return meta[r].APIBaseURL
}
// AppBaseURL returns the Aapp base URL for the region.
func (r Region) AppBaseURL() string {
return meta[r].AppBaseURL
}