-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add X-Auth-Token support - removed old Resell client - removed old QuotaManager client - created one client (all in one) that includes clients Resell and QuotaManager - new client uses X-Auth-Token instead of X-Token - updated Go version (1.14 -> 1.20) - Resell URL is taken from the identity service - added support auth with user from another domain (different from scope) - removed context for every request, because gophercloud doesn't support it
- Loading branch information
Showing
82 changed files
with
1,712 additions
and
1,793 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
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 |
---|---|---|
@@ -1,5 +1,8 @@ | ||
module github.com/selectel/go-selvpcclient/v2 | ||
module github.com/selectel/go-selvpcclient/v3 | ||
|
||
go 1.14 | ||
go 1.20 | ||
|
||
require github.com/gophercloud/gophercloud v1.0.0 | ||
require ( | ||
github.com/google/go-querystring v1.1.0 | ||
github.com/gophercloud/gophercloud v1.5.0 | ||
) |
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 |
---|---|---|
@@ -1,12 +1,17 @@ | ||
github.com/gophercloud/gophercloud v1.0.0 h1:9nTGx0jizmHxDobe4mck89FyQHVyA3CaXLIUSGJjP9k= | ||
github.com/gophercloud/gophercloud v1.0.0/go.mod h1:Q8fZtyi5zZxPS/j9aj3sSxtvj41AdQMDwyo1myduD5c= | ||
golang.org/x/crypto v0.0.0-20211202192323-5770296d904e/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= | ||
github.com/google/go-cmp v0.5.2 h1:X2ev0eStA3AbceY54o37/0PQ/UWqKEiiO2dKL5OPaFM= | ||
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= | ||
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8= | ||
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU= | ||
github.com/gophercloud/gophercloud v1.5.0 h1:cDN6XFCLKiiqvYpjQLq9AiM7RDRbIC9450WpPH+yvXo= | ||
github.com/gophercloud/gophercloud v1.5.0/go.mod h1:aAVqcocTSXh2vYFZ1JTvx4EQmfgzxRcNupUfxZbBNDM= | ||
golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= | ||
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= | ||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= | ||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= | ||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= | ||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= | ||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | ||
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= |
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,39 @@ | ||
package clients | ||
|
||
import ( | ||
"fmt" | ||
|
||
clientservices "github.com/selectel/go-selvpcclient/v3/selvpcclient/clients/services" | ||
) | ||
|
||
const ( | ||
QuotaManagerServiceType = "quota-manager" | ||
) | ||
|
||
// QuotaManagerClient quota-manager client with X-Auth-Token authorization. | ||
type QuotaManagerClient struct { | ||
Requests *clientservices.RequestService | ||
catalog *clientservices.CatalogService | ||
} | ||
|
||
func NewQuotaManagerClient( | ||
requestService *clientservices.RequestService, | ||
catalogService *clientservices.CatalogService, | ||
) *QuotaManagerClient { | ||
return &QuotaManagerClient{ | ||
Requests: requestService, | ||
catalog: catalogService, | ||
} | ||
} | ||
|
||
// GetEndpoint - returns service url in specific region. | ||
func (c *QuotaManagerClient) GetEndpoint(regionName string) (string, error) { | ||
endpoint, err := c.catalog.GetEndpoint(QuotaManagerServiceType, regionName) | ||
if err != nil { | ||
return "", fmt.Errorf( | ||
"failed to resolve endpoint for %s in %s, err: %w", QuotaManagerServiceType, regionName, err, | ||
) | ||
} | ||
|
||
return endpoint.URL, nil | ||
} |
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,40 @@ | ||
package clients | ||
|
||
import ( | ||
"fmt" | ||
|
||
clientservices "github.com/selectel/go-selvpcclient/v3/selvpcclient/clients/services" | ||
) | ||
|
||
const ( | ||
ResellServiceType = "resell" | ||
ResellAPIVersion = "v2" | ||
) | ||
|
||
// ResellClient resell client with X-Auth-Token authorization. | ||
type ResellClient struct { | ||
Requests *clientservices.RequestService | ||
catalog *clientservices.CatalogService | ||
} | ||
|
||
func NewResellClient( | ||
requestService *clientservices.RequestService, | ||
catalogService *clientservices.CatalogService, | ||
) *ResellClient { | ||
return &ResellClient{ | ||
Requests: requestService, | ||
catalog: catalogService, | ||
} | ||
} | ||
|
||
// GetEndpoint - returns service url. | ||
func (c *ResellClient) GetEndpoint() (string, error) { | ||
endpoints, err := c.catalog.GetEndpoints(ResellServiceType) | ||
if err != nil { | ||
return "", fmt.Errorf("failed to resolve endpoint for %s, err: %w", ResellServiceType, err) | ||
} | ||
|
||
url := fmt.Sprintf("%s/%s", endpoints[0].URL, ResellAPIVersion) | ||
|
||
return url, nil | ||
} |
Oops, something went wrong.