forked from ppc64le-cloud/powervs-utils
-
Notifications
You must be signed in to change notification settings - Fork 0
/
region.go
35 lines (33 loc) · 874 Bytes
/
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
package utils
import (
"fmt"
"strings"
)
func GetRegion(zone string) (region string, err error) {
err = nil
switch {
case strings.HasPrefix(zone, "dal"), strings.HasPrefix(zone, "us-south"):
region = "us-south"
case strings.HasPrefix(zone, "sao"):
region = "sao"
case strings.HasPrefix(zone, "us-east"):
region = "us-east"
case strings.HasPrefix(zone, "tor"):
region = "tor"
case strings.HasPrefix(zone, "eu-de-"):
region = "eu-de"
case strings.HasPrefix(zone, "lon"):
region = "lon"
case strings.HasPrefix(zone, "syd"):
region = "syd"
case strings.HasPrefix(zone, "tok"):
region = "tok"
case strings.HasPrefix(zone, "osa"):
region = "osa"
case strings.HasPrefix(zone, "mon"):
region = "mon"
default:
return "", fmt.Errorf("region not found for the zone, talk to the developer to add the support into the tool: %s", zone)
}
return
}