-
Notifications
You must be signed in to change notification settings - Fork 408
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow ovh provider to connect to other endpoints than EU (#2625)
This introduces the `endpoint` provider configuration parameter. If not provided the provider will connect to the EU region for backward compatibility. The `endpoint` can be set to `eu`, `us` or `ca` depending on the OVH region the use wants to manage domains and zones in. It can also be set to any arbitrary URL for future OVH regions.
- Loading branch information
Showing
4 changed files
with
88 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package ovh | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/ovh/go-ovh/ovh" | ||
) | ||
|
||
func Test_getOVHEndpoint(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
endpoint string | ||
want string | ||
}{ | ||
{ | ||
"default to EU", "", ovh.OvhEU, | ||
}, | ||
{ | ||
"default to EU if omitted", "omitted", ovh.OvhEU, | ||
}, | ||
{ | ||
"set to EU", "eu", ovh.OvhEU, | ||
}, | ||
{ | ||
"set to CA", "ca", ovh.OvhCA, | ||
}, | ||
{ | ||
"set to US", "eu", ovh.OvhUS, | ||
}, | ||
{ | ||
"case insensitive", "Eu", ovh.OvhEU, | ||
}, | ||
{ | ||
"case insensitive ca", "CA", ovh.OvhCA, | ||
}, | ||
{ | ||
"arbitratry", "https://blah", "https://blah", | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
params := make(map[string]string) | ||
if tt.endpoint != "" && tt.endpoint != "omitted" { | ||
params["endpoint"] = tt.endpoint | ||
} | ||
if got := getOVHEndpoint(params); got != tt.want { | ||
t.Errorf("getOVHEndpoint() = %v, want %v", got, tt.want) | ||
} | ||
}) | ||
} | ||
} |