Skip to content

Commit

Permalink
feat: add support for pl-waw-1 zone and pl-waw region (#557)
Browse files Browse the repository at this point in the history
  • Loading branch information
remyleone authored Sep 23, 2020
1 parent 3c87d95 commit ae5d788
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
4 changes: 2 additions & 2 deletions scw/client_option_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func TestClientOptions(t *testing.T) {
s.token = auth.NewToken(testAccessKey, testSecretKey)
s.defaultRegion = &v
},
errStr: "scaleway-sdk-go: invalid default region format 'invalid', available regions are: fr-par, nl-ams",
errStr: "scaleway-sdk-go: invalid default region format 'invalid', available regions are: fr-par, nl-ams, pl-waw",
},
{
name: "Should throw a zone error",
Expand All @@ -135,7 +135,7 @@ func TestClientOptions(t *testing.T) {
s.token = auth.NewToken(testAccessKey, testSecretKey)
s.defaultZone = &v
},
errStr: "scaleway-sdk-go: invalid default zone format 'invalid', available zones are: fr-par-1, fr-par-2, nl-ams-1",
errStr: "scaleway-sdk-go: invalid default zone format 'invalid', available zones are: fr-par-1, fr-par-2, nl-ams-1, pl-waw-1",
},
}

Expand Down
8 changes: 8 additions & 0 deletions scw/locality.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ const (
ZoneFrPar2 = Zone("fr-par-2")
// ZoneNlAms1 represents the nl-ams-1 zone
ZoneNlAms1 = Zone("nl-ams-1")
// ZonePlWaw1 represents the pl-waw-1 zone
ZonePlWaw1 = Zone("pl-waw-1")
)

var (
Expand All @@ -31,6 +33,7 @@ var (
ZoneFrPar1,
ZoneFrPar2,
ZoneNlAms1,
ZonePlWaw1,
}
)

Expand Down Expand Up @@ -68,13 +71,16 @@ const (
RegionFrPar = Region("fr-par")
// RegionNlAms represents the nl-ams region
RegionNlAms = Region("nl-ams")
// RegionPlWaw represents the pl-waw region
RegionPlWaw = Region("pl-waw")
)

var (
// AllRegions is an array that list all regions
AllRegions = []Region{
RegionFrPar,
RegionNlAms,
RegionPlWaw,
}
)

Expand All @@ -95,6 +101,8 @@ func (region Region) GetZones() []Zone {
return []Zone{ZoneFrPar1, ZoneFrPar2}
case RegionNlAms:
return []Zone{ZoneNlAms1}
case RegionPlWaw:
return []Zone{ZonePlWaw1}
default:
return []Zone{}
}
Expand Down
18 changes: 13 additions & 5 deletions scw/locality_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ func TestParseZone(t *testing.T) {
input: "fr-par-1",
expected: ZoneFrPar1,
},
{
input: "pl-waw-1",
expected: ZonePlWaw1,
},
{
input: "par1",
expected: ZoneFrPar1,
Expand All @@ -33,17 +37,17 @@ func TestParseZone(t *testing.T) {
{
input: "fr-par",
expected: "",
err: errors.New("bad zone format, available zones are: fr-par-1, fr-par-2, nl-ams-1"),
err: errors.New("bad zone format, available zones are: fr-par-1, fr-par-2, nl-ams-1, pl-waw-1"),
},
{
input: "fr-par-n",
expected: "",
err: errors.New("bad zone format, available zones are: fr-par-1, fr-par-2, nl-ams-1"),
err: errors.New("bad zone format, available zones are: fr-par-1, fr-par-2, nl-ams-1, pl-waw-1"),
},
{
input: "fr-par-0",
expected: "",
err: errors.New("bad zone format, available zones are: fr-par-1, fr-par-2, nl-ams-1"),
err: errors.New("bad zone format, available zones are: fr-par-1, fr-par-2, nl-ams-1, pl-waw-1"),
},
}

Expand Down Expand Up @@ -96,19 +100,23 @@ func TestParseRegion(t *testing.T) {
input: "ams1",
expected: RegionNlAms,
},
{
input: "pl-waw",
expected: RegionPlWaw,
},
{
input: "xx-xxx",
expected: "xx-xxx",
},
{
input: "fr-par-1",
expected: "",
err: errors.New("bad region format, available regions are: fr-par, nl-ams"),
err: errors.New("bad region format, available regions are: fr-par, nl-ams, pl-waw"),
},
{
input: "fr-pa1",
expected: "",
err: errors.New("bad region format, available regions are: fr-par, nl-ams"),
err: errors.New("bad region format, available regions are: fr-par, nl-ams, pl-waw"),
},
}

Expand Down

0 comments on commit ae5d788

Please sign in to comment.