Skip to content

Commit

Permalink
V3: Get zone name from URL
Browse files Browse the repository at this point in the history
Signed-off-by: Pierre-Emmanuel Jacquier <15922119+pierre-emmanuelJ@users.noreply.github.com>
  • Loading branch information
pierre-emmanuelJ committed Jan 17, 2024
1 parent 0bb7eb1 commit 1ace995
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
11 changes: 11 additions & 0 deletions v3/client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions v3/generator/client/client.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@ const (
{{ .Enum }}
)

// Zone gets the zone name from the URL.
func (u URL) Zone() (string, bool) {
for zone, url := range Zones {
if url == u {
return zone, true
}
}

return "", false
}

// Zones represents a list of all Exoscale zone.
var Zones map[string]URL = map[string]URL{
{{ .Zones }}
Expand Down

0 comments on commit 1ace995

Please sign in to comment.