Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PowerVS: Support newly added regions #7

Merged
merged 1 commit into from
Jan 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,17 @@
# powervs-utils
# powervs-utils

## Building

Build it with

```
$ go build -v ./...
```

## Testing

And test it with

```
$ go test -v ./...
```
27 changes: 26 additions & 1 deletion region.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ func GetRegion(zone string) (region string, err error) {
region = "osa"
case strings.HasPrefix(zone, "mon"):
region = "mon"
case strings.HasPrefix(zone, "mad"):
region = "mad"
case strings.HasPrefix(zone, "wdc"):
region = "wdc"
default:
return "", fmt.Errorf("region not found for the zone, talk to the developer to add the support into the tool: %s", zone)
}
Expand Down Expand Up @@ -70,6 +74,15 @@ var Regions = map[string]Region{
"lon06",
},
},
"mad": {
Description: "Madrid, Spain",
VPCRegion: "eu-es",
COSRegion: "eu-es",
Zones: []string{
"mad02",
"mad04",
},
},
"mon": {
Description: "Montreal, Canada",
VPCRegion: "ca-tor",
Expand All @@ -95,7 +108,10 @@ var Regions = map[string]Region{
Description: "São Paulo, Brazil",
VPCRegion: "br-sao",
COSRegion: "br-sao",
Zones: []string{"sao01"},
Zones: []string{
"sao01",
"sao04",
},
},
"tok": {
Description: "Tokyo, Japan",
Expand All @@ -109,6 +125,15 @@ var Regions = map[string]Region{
COSRegion: "us-east",
Zones: []string{"us-east"},
},
"wdc": {
Description: "Washington DC, USA",
VPCRegion: "us-east",
COSRegion: "us-east",
Zones: []string{
"wdc06",
"wdc07",
},
},
}

// VPCRegionForPowerVSRegion returns the VPC region for the specified PowerVS region.
Expand Down
30 changes: 30 additions & 0 deletions region_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,30 @@ func TestGetRegion(t *testing.T) {
"sao",
false,
},
{
"Sao Paulo 04",
args{"sao04"},
"sao",
false,
},
{
"Washington DC",
args{"us-east"},
"us-east",
false,
},
{
"Washington DC 06",
args{"wdc06"},
"wdc",
false,
},
{
"Washington DC 07",
args{"wdc07"},
"wdc",
false,
},
{
"Toronto",
args{"tor01"},
Expand Down Expand Up @@ -86,6 +104,18 @@ func TestGetRegion(t *testing.T) {
"osa",
false,
},
{
"Madrid 02",
args{"mad02"},
"mad",
false,
},
{
"Madrid 04",
args{"mad04"},
"mad",
false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down