build(deps): bump the go-deps group across 1 directory with 14 updates

Bumps the go-deps group with 11 updates in the / directory:

| Package | From | To |
| --- | --- | --- |
| [cloud.google.com/go/compute](https://github.com/googleapis/google-cloud-go) | `1.25.1` | `1.26.0` |
| [github.com/Azure/azure-sdk-for-go/sdk/azidentity](https://github.com/Azure/azure-sdk-for-go) | `1.5.1` | `1.5.2` |
| [github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v5](https://github.com/Azure/azure-sdk-for-go) | `5.5.0` | `5.7.0` |
| [github.com/aws/aws-sdk-go](https://github.com/aws/aws-sdk-go) | `1.51.25` | `1.52.0` |
| [github.com/getsentry/sentry-go](https://github.com/getsentry/sentry-go) | `0.26.0` | `0.27.0` |
| [github.com/gophercloud/gophercloud](https://github.com/gophercloud/gophercloud) | `1.10.0` | `1.11.0` |
| [github.com/jackc/pgtype](https://github.com/jackc/pgtype) | `1.14.1` | `1.14.3` |
| [github.com/labstack/echo/v4](https://github.com/labstack/echo) | `4.11.4` | `4.12.0` |
| [github.com/openshift-online/ocm-sdk-go](https://github.com/openshift-online/ocm-sdk-go) | `0.1.398` | `0.1.418` |
| [github.com/osbuild/images](https://github.com/osbuild/images) | `0.56.0` | `0.58.0` |
| [github.com/prometheus/client_golang](https://github.com/prometheus/client_golang) | `1.18.0` | `1.19.0` |



Updates `cloud.google.com/go/compute` from 1.25.1 to 1.26.0
- [Release notes](https://github.com/googleapis/google-cloud-go/releases)
- [Changelog](https://github.com/googleapis/google-cloud-go/blob/main/documentai/CHANGES.md)
- [Commits](https://github.com/googleapis/google-cloud-go/compare/pubsub/v1.25.1...pubsub/v1.26.0)

Updates `github.com/Azure/azure-sdk-for-go/sdk/azidentity` from 1.5.1 to 1.5.2
- [Release notes](https://github.com/Azure/azure-sdk-for-go/releases)
- [Changelog](https://github.com/Azure/azure-sdk-for-go/blob/main/documentation/release.md)
- [Commits](https://github.com/Azure/azure-sdk-for-go/compare/sdk/internal/v1.5.1...sdk/internal/v1.5.2)

Updates `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v5` from 5.5.0 to 5.7.0
- [Release notes](https://github.com/Azure/azure-sdk-for-go/releases)
- [Changelog](https://github.com/Azure/azure-sdk-for-go/blob/main/documentation/release.md)
- [Commits](https://github.com/Azure/azure-sdk-for-go/compare/sdk/resourcemanager/compute/armcompute/v5.5.0...sdk/resourcemanager/compute/armcompute/v5.7.0)

Updates `github.com/aws/aws-sdk-go` from 1.51.25 to 1.52.0
- [Release notes](https://github.com/aws/aws-sdk-go/releases)
- [Commits](https://github.com/aws/aws-sdk-go/compare/v1.51.25...v1.52.0)

Updates `github.com/getsentry/sentry-go` from 0.26.0 to 0.27.0
- [Release notes](https://github.com/getsentry/sentry-go/releases)
- [Changelog](https://github.com/getsentry/sentry-go/blob/master/CHANGELOG.md)
- [Commits](https://github.com/getsentry/sentry-go/compare/v0.26.0...v0.27.0)

Updates `github.com/gophercloud/gophercloud` from 1.10.0 to 1.11.0
- [Release notes](https://github.com/gophercloud/gophercloud/releases)
- [Changelog](https://github.com/gophercloud/gophercloud/blob/v1.11.0/CHANGELOG.md)
- [Commits](https://github.com/gophercloud/gophercloud/compare/v1.10.0...v1.11.0)

Updates `github.com/jackc/pgtype` from 1.14.1 to 1.14.3
- [Changelog](https://github.com/jackc/pgtype/blob/master/CHANGELOG.md)
- [Commits](https://github.com/jackc/pgtype/compare/v1.14.1...v1.14.3)

Updates `github.com/jackc/pgx/v4` from 4.18.1 to 4.18.2
- [Changelog](https://github.com/jackc/pgx/blob/v4.18.2/CHANGELOG.md)
- [Commits](https://github.com/jackc/pgx/compare/v4.18.1...v4.18.2)

Updates `github.com/labstack/echo/v4` from 4.11.4 to 4.12.0
- [Release notes](https://github.com/labstack/echo/releases)
- [Changelog](https://github.com/labstack/echo/blob/master/CHANGELOG.md)
- [Commits](https://github.com/labstack/echo/compare/v4.11.4...v4.12.0)

Updates `github.com/openshift-online/ocm-sdk-go` from 0.1.398 to 0.1.418
- [Release notes](https://github.com/openshift-online/ocm-sdk-go/releases)
- [Changelog](https://github.com/openshift-online/ocm-sdk-go/blob/main/CHANGES.md)
- [Commits](https://github.com/openshift-online/ocm-sdk-go/compare/v0.1.398...v0.1.418)

Updates `github.com/osbuild/images` from 0.56.0 to 0.58.0
- [Release notes](https://github.com/osbuild/images/releases)
- [Commits](https://github.com/osbuild/images/compare/v0.56.0...v0.58.0)

Updates `github.com/prometheus/client_golang` from 1.18.0 to 1.19.0
- [Release notes](https://github.com/prometheus/client_golang/releases)
- [Changelog](https://github.com/prometheus/client_golang/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prometheus/client_golang/compare/v1.18.0...v1.19.0)

Updates `golang.org/x/sync` from 0.6.0 to 0.7.0
- [Commits](https://github.com/golang/sync/compare/v0.6.0...v0.7.0)

Updates `google.golang.org/api` from 0.175.0 to 0.177.0
- [Release notes](https://github.com/googleapis/google-api-go-client/releases)
- [Changelog](https://github.com/googleapis/google-api-go-client/blob/main/CHANGES.md)
- [Commits](https://github.com/googleapis/google-api-go-client/compare/v0.175.0...v0.177.0)

---
updated-dependencies:
- dependency-name: cloud.google.com/go/compute
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: go-deps
- dependency-name: github.com/Azure/azure-sdk-for-go/sdk/azidentity
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: go-deps
- dependency-name: github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v5
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: go-deps
- dependency-name: github.com/aws/aws-sdk-go
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: go-deps
- dependency-name: github.com/getsentry/sentry-go
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: go-deps
- dependency-name: github.com/gophercloud/gophercloud
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: go-deps
- dependency-name: github.com/jackc/pgtype
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: go-deps
- dependency-name: github.com/jackc/pgx/v4
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: go-deps
- dependency-name: github.com/labstack/echo/v4
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: go-deps
- dependency-name: github.com/openshift-online/ocm-sdk-go
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: go-deps
- dependency-name: github.com/osbuild/images
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: go-deps
- dependency-name: github.com/prometheus/client_golang
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: go-deps
- dependency-name: golang.org/x/sync
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: go-deps
- dependency-name: google.golang.org/api
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: go-deps
...

Signed-off-by: dependabot[bot] <support@github.com>
This commit is contained in:
dependabot[bot] 2024-05-02 04:46:13 +00:00 committed by Achilleas Koutsou
parent 49566b7ce4
commit 9193f3eebc
285 changed files with 70293 additions and 63914 deletions

View file

@ -1,7 +1,6 @@
package openstack
import (
"context"
"fmt"
"reflect"
"strings"
@ -24,18 +23,20 @@ const (
v3 = "v3"
)
// NewClient prepares an unauthenticated ProviderClient instance.
// Most users will probably prefer using the AuthenticatedClient function
// instead.
//
// This is useful if you wish to explicitly control the version of the identity
// service that's used for authentication explicitly, for example.
//
// A basic example of using this would be:
//
// ao, err := openstack.AuthOptionsFromEnv()
// provider, err := openstack.NewClient(ao.IdentityEndpoint)
// client, err := openstack.NewIdentityV3(provider, gophercloud.EndpointOpts{})
/*
NewClient prepares an unauthenticated ProviderClient instance.
Most users will probably prefer using the AuthenticatedClient function
instead.
This is useful if you wish to explicitly control the version of the identity
service that's used for authentication explicitly, for example.
A basic example of using this would be:
ao, err := openstack.AuthOptionsFromEnv()
provider, err := openstack.NewClient(ao.IdentityEndpoint)
client, err := openstack.NewIdentityV3(provider, gophercloud.EndpointOpts{})
*/
func NewClient(endpoint string) (*gophercloud.ProviderClient, error) {
base, err := utils.BaseEndpoint(endpoint)
if err != nil {
@ -53,45 +54,42 @@ func NewClient(endpoint string) (*gophercloud.ProviderClient, error) {
return p, nil
}
// AuthenticatedClientWithContext logs in to an OpenStack cloud found at the identity endpoint
// specified by the options, acquires a token, and returns a Provider Client
// instance that's ready to operate.
//
// If the full path to a versioned identity endpoint was specified (example:
// http://example.com:5000/v3), that path will be used as the endpoint to query.
//
// If a versionless endpoint was specified (example: http://example.com:5000/),
// the endpoint will be queried to determine which versions of the identity service
// are available, then chooses the most recent or most supported version.
//
// Example:
//
// ao, err := openstack.AuthOptionsFromEnv()
// provider, err := openstack.AuthenticatedClientWithContext(ctx, ao)
// client, err := openstack.NewNetworkV2(provider, gophercloud.EndpointOpts{
// Region: os.Getenv("OS_REGION_NAME"),
// })
func AuthenticatedClientWithContext(ctx context.Context, options gophercloud.AuthOptions) (*gophercloud.ProviderClient, error) {
/*
AuthenticatedClient logs in to an OpenStack cloud found at the identity endpoint
specified by the options, acquires a token, and returns a Provider Client
instance that's ready to operate.
If the full path to a versioned identity endpoint was specified (example:
http://example.com:5000/v3), that path will be used as the endpoint to query.
If a versionless endpoint was specified (example: http://example.com:5000/),
the endpoint will be queried to determine which versions of the identity service
are available, then chooses the most recent or most supported version.
Example:
ao, err := openstack.AuthOptionsFromEnv()
provider, err := openstack.AuthenticatedClient(ao)
client, err := openstack.NewNetworkV2(provider, gophercloud.EndpointOpts{
Region: os.Getenv("OS_REGION_NAME"),
})
*/
func AuthenticatedClient(options gophercloud.AuthOptions) (*gophercloud.ProviderClient, error) {
client, err := NewClient(options.IdentityEndpoint)
if err != nil {
return nil, err
}
err = AuthenticateWithContext(ctx, client, options)
err = Authenticate(client, options)
if err != nil {
return nil, err
}
return client, nil
}
// AuthenticatedClient is a compatibility wrapper around AuthenticatedClientWithContext
func AuthenticatedClient(options gophercloud.AuthOptions) (*gophercloud.ProviderClient, error) {
return AuthenticatedClientWithContext(context.Background(), options)
}
// AuthenticateWithContext authenticates or re-authenticates against the most
// recent identity service supported at the provided endpoint.
func AuthenticateWithContext(ctx context.Context, client *gophercloud.ProviderClient, options gophercloud.AuthOptions) error {
// Authenticate or re-authenticate against the most recent identity service
// supported at the provided endpoint.
func Authenticate(client *gophercloud.ProviderClient, options gophercloud.AuthOptions) error {
versions := []*utils.Version{
{ID: v2, Priority: 20, Suffix: "/v2.0/"},
{ID: v3, Priority: 30, Suffix: "/v3/"},
@ -104,31 +102,21 @@ func AuthenticateWithContext(ctx context.Context, client *gophercloud.ProviderCl
switch chosen.ID {
case v2:
return v2auth(ctx, client, endpoint, options, gophercloud.EndpointOpts{})
return v2auth(client, endpoint, options, gophercloud.EndpointOpts{})
case v3:
return v3auth(ctx, client, endpoint, &options, gophercloud.EndpointOpts{})
return v3auth(client, endpoint, &options, gophercloud.EndpointOpts{})
default:
// The switch statement must be out of date from the versions list.
return fmt.Errorf("Unrecognized identity version: %s", chosen.ID)
}
}
// Authenticate is a compatibility wrapper around AuthenticateWithContext.
func Authenticate(client *gophercloud.ProviderClient, options gophercloud.AuthOptions) error {
return AuthenticateWithContext(context.Background(), client, options)
}
// AuthenticateV2WithContext explicitly authenticates against the identity v2 endpoint.
func AuthenticateV2WithContext(ctx context.Context, client *gophercloud.ProviderClient, options gophercloud.AuthOptions, eo gophercloud.EndpointOpts) error {
return v2auth(ctx, client, "", options, eo)
}
// AuthenticateV2 is a compatibility wrapper around AuthenticateV2WithContext.
// AuthenticateV2 explicitly authenticates against the identity v2 endpoint.
func AuthenticateV2(client *gophercloud.ProviderClient, options gophercloud.AuthOptions, eo gophercloud.EndpointOpts) error {
return AuthenticateV2WithContext(context.Background(), client, options, eo)
return v2auth(client, "", options, eo)
}
func v2auth(ctx context.Context, client *gophercloud.ProviderClient, endpoint string, options gophercloud.AuthOptions, eo gophercloud.EndpointOpts) error {
func v2auth(client *gophercloud.ProviderClient, endpoint string, options gophercloud.AuthOptions, eo gophercloud.EndpointOpts) error {
v2Client, err := NewIdentityV2(client, eo)
if err != nil {
return err
@ -148,7 +136,7 @@ func v2auth(ctx context.Context, client *gophercloud.ProviderClient, endpoint st
TokenID: options.TokenID,
}
result := tokens2.CreateWithContext(ctx, v2Client, v2Opts)
result := tokens2.Create(v2Client, v2Opts)
err = client.SetTokenAndAuthResult(result)
if err != nil {
@ -171,7 +159,7 @@ func v2auth(ctx context.Context, client *gophercloud.ProviderClient, endpoint st
tao := options
tao.AllowReauth = false
client.ReauthFunc = func() error {
err := v2auth(context.Background(), &tac, endpoint, tao, eo)
err := v2auth(&tac, endpoint, tao, eo)
if err != nil {
return err
}
@ -186,17 +174,12 @@ func v2auth(ctx context.Context, client *gophercloud.ProviderClient, endpoint st
return nil
}
// AuthenticateV3WithContext explicitly authenticates against the identity v3 service.
func AuthenticateV3WithContext(ctx context.Context, client *gophercloud.ProviderClient, options tokens3.AuthOptionsBuilder, eo gophercloud.EndpointOpts) error {
return v3auth(ctx, client, "", options, eo)
}
// AuthenticateV3 is a compatibility wrapper around AuthenticateV3WithContext
// AuthenticateV3 explicitly authenticates against the identity v3 service.
func AuthenticateV3(client *gophercloud.ProviderClient, options tokens3.AuthOptionsBuilder, eo gophercloud.EndpointOpts) error {
return AuthenticateV3WithContext(context.Background(), client, options, eo)
return v3auth(client, "", options, eo)
}
func v3auth(ctx context.Context, client *gophercloud.ProviderClient, endpoint string, opts tokens3.AuthOptionsBuilder, eo gophercloud.EndpointOpts) error {
func v3auth(client *gophercloud.ProviderClient, endpoint string, opts tokens3.AuthOptionsBuilder, eo gophercloud.EndpointOpts) error {
// Override the generated service endpoint with the one returned by the version endpoint.
v3Client, err := NewIdentityV3(client, eo)
if err != nil {
@ -246,11 +229,11 @@ func v3auth(ctx context.Context, client *gophercloud.ProviderClient, endpoint st
var result tokens3.CreateResult
switch opts.(type) {
case *ec2tokens.AuthOptions:
result = ec2tokens.CreateWithContext(ctx, v3Client, opts)
result = ec2tokens.Create(v3Client, opts)
case *oauth1.AuthOptions:
result = oauth1.CreateWithContext(ctx, v3Client, opts)
result = oauth1.Create(v3Client, opts)
default:
result = tokens3.CreateWithContext(ctx, v3Client, opts)
result = tokens3.Create(v3Client, opts)
}
err = client.SetTokenAndAuthResult(result)
@ -294,7 +277,7 @@ func v3auth(ctx context.Context, client *gophercloud.ProviderClient, endpoint st
tao = opts
}
client.ReauthFunc = func() error {
err := v3auth(context.Background(), &tac, endpoint, tao, eo)
err := v3auth(&tac, endpoint, tao, eo)
if err != nil {
return err
}

View file

@ -1,10 +1,6 @@
package tokens
import (
"context"
"github.com/gophercloud/gophercloud"
)
import "github.com/gophercloud/gophercloud"
// PasswordCredentialsV2 represents the required options to authenticate
// with a username and password.
@ -81,17 +77,17 @@ func (opts AuthOptions) ToTokenV2CreateMap() (map[string]interface{}, error) {
return b, nil
}
// CreateWithContext authenticates to the identity service and attempts to acquire a Token.
// Create authenticates to the identity service and attempts to acquire a Token.
// Generally, rather than interact with this call directly, end users should
// call openstack.AuthenticatedClient(), which abstracts all of the gory details
// about navigating service catalogs and such.
func CreateWithContext(ctx context.Context, client *gophercloud.ServiceClient, auth AuthOptionsBuilder) (r CreateResult) {
func Create(client *gophercloud.ServiceClient, auth AuthOptionsBuilder) (r CreateResult) {
b, err := auth.ToTokenV2CreateMap()
if err != nil {
r.Err = err
return
}
resp, err := client.PostWithContext(ctx, CreateURL(client), b, &r.Body, &gophercloud.RequestOpts{
resp, err := client.Post(CreateURL(client), b, &r.Body, &gophercloud.RequestOpts{
OkCodes: []int{200, 203},
OmitHeaders: []string{"X-Auth-Token"},
})
@ -99,21 +95,11 @@ func CreateWithContext(ctx context.Context, client *gophercloud.ServiceClient, a
return
}
// Create is a compatibility wrapper around CreateWithContext
func Create(client *gophercloud.ServiceClient, auth AuthOptionsBuilder) (r CreateResult) {
return CreateWithContext(context.Background(), client, auth)
}
// GetWithContext validates and retrieves information for user's token.
func GetWithContext(ctx context.Context, client *gophercloud.ServiceClient, token string) (r GetResult) {
// Get validates and retrieves information for user's token.
func Get(client *gophercloud.ServiceClient, token string) (r GetResult) {
resp, err := client.Get(GetURL(client, token), &r.Body, &gophercloud.RequestOpts{
OkCodes: []int{200, 203},
})
_, r.Header, r.Err = gophercloud.ParseResponse(resp, err)
return
}
// Get is a compatibility wrapper around GetWithContext
func Get(client *gophercloud.ServiceClient, token string) (r GetResult) {
return GetWithContext(context.Background(), client, token)
}

View file

@ -1,7 +1,6 @@
package ec2tokens
import (
"context"
"crypto/hmac"
"crypto/sha1"
"crypto/sha256"
@ -288,8 +287,8 @@ func (opts *AuthOptions) ToTokenV3CreateMap(map[string]interface{}) (map[string]
return b, nil
}
// CreateWithContext authenticates and either generates a new token from EC2 credentials
func CreateWithContext(ctx context.Context, c *gophercloud.ServiceClient, opts tokens.AuthOptionsBuilder) (r tokens.CreateResult) {
// Create authenticates and either generates a new token from EC2 credentials
func Create(c *gophercloud.ServiceClient, opts tokens.AuthOptionsBuilder) (r tokens.CreateResult) {
b, err := opts.ToTokenV3CreateMap(nil)
if err != nil {
r.Err = err
@ -299,7 +298,7 @@ func CreateWithContext(ctx context.Context, c *gophercloud.ServiceClient, opts t
// delete "token" element, since it is used in s3tokens
deleteBodyElements(b, "token")
resp, err := c.PostWithContext(ctx, ec2tokensURL(c), b, &r.Body, &gophercloud.RequestOpts{
resp, err := c.Post(ec2tokensURL(c), b, &r.Body, &gophercloud.RequestOpts{
MoreHeaders: map[string]string{"X-Auth-Token": ""},
OkCodes: []int{200},
})
@ -307,15 +306,9 @@ func CreateWithContext(ctx context.Context, c *gophercloud.ServiceClient, opts t
return
}
// Create is a compatibility wrapper around CreateWithContext
func Create(c *gophercloud.ServiceClient, opts tokens.AuthOptionsBuilder) (r tokens.CreateResult) {
return CreateWithContext(context.Background(), c, opts)
}
// ValidateS3TokenWithContext authenticates an S3 request using EC2
// credentials. Doesn't generate a new token ID, but returns a
// tokens.CreateResult.
func ValidateS3TokenWithContext(ctx context.Context, c *gophercloud.ServiceClient, opts tokens.AuthOptionsBuilder) (r tokens.CreateResult) {
// ValidateS3Token authenticates an S3 request using EC2 credentials. Doesn't
// generate a new token ID, but returns a tokens.CreateResult.
func ValidateS3Token(c *gophercloud.ServiceClient, opts tokens.AuthOptionsBuilder) (r tokens.CreateResult) {
b, err := opts.ToTokenV3CreateMap(nil)
if err != nil {
r.Err = err
@ -325,7 +318,7 @@ func ValidateS3TokenWithContext(ctx context.Context, c *gophercloud.ServiceClien
// delete unused element, since it is used in ec2tokens only
deleteBodyElements(b, "body_hash", "headers", "host", "params", "path", "verb")
resp, err := c.PostWithContext(ctx, s3tokensURL(c), b, &r.Body, &gophercloud.RequestOpts{
resp, err := c.Post(s3tokensURL(c), b, &r.Body, &gophercloud.RequestOpts{
MoreHeaders: map[string]string{"X-Auth-Token": ""},
OkCodes: []int{200},
})
@ -333,11 +326,6 @@ func ValidateS3TokenWithContext(ctx context.Context, c *gophercloud.ServiceClien
return
}
// ValidateS3Token is a compatibility wrapper around ValidateS3TokenWithContext
func ValidateS3Token(c *gophercloud.ServiceClient, opts tokens.AuthOptionsBuilder) (r tokens.CreateResult) {
return ValidateS3TokenWithContext(context.Background(), c, opts)
}
// The following are small helper functions used to help build the signature.
// sumHMAC1 is a func to implement the HMAC SHA1 signature method.

View file

@ -1,7 +1,6 @@
package oauth1
import (
"context"
"crypto/hmac"
"crypto/sha1"
"encoding/base64"
@ -134,9 +133,9 @@ func (opts AuthOptions) ToTokenV3CreateMap(map[string]interface{}) (map[string]i
return gophercloud.BuildRequestBody(req, "")
}
// CreateWithContext authenticates and either generates a new OpenStack token
// from an OAuth1 token.
func CreateWithContext(ctx context.Context, client *gophercloud.ServiceClient, opts tokens.AuthOptionsBuilder) (r tokens.CreateResult) {
// Create authenticates and either generates a new OpenStack token from an
// OAuth1 token.
func Create(client *gophercloud.ServiceClient, opts tokens.AuthOptionsBuilder) (r tokens.CreateResult) {
b, err := opts.ToTokenV3CreateMap(nil)
if err != nil {
r.Err = err
@ -154,7 +153,7 @@ func CreateWithContext(ctx context.Context, client *gophercloud.ServiceClient, o
return
}
resp, err := client.PostWithContext(ctx, authURL(client), b, &r.Body, &gophercloud.RequestOpts{
resp, err := client.Post(authURL(client), b, &r.Body, &gophercloud.RequestOpts{
MoreHeaders: h,
OkCodes: []int{201},
})
@ -162,11 +161,6 @@ func CreateWithContext(ctx context.Context, client *gophercloud.ServiceClient, o
return
}
// Create is a compatibility wrapper around CreateWithContext.
func Create(client *gophercloud.ServiceClient, opts tokens.AuthOptionsBuilder) (r tokens.CreateResult) {
return CreateWithContext(context.Background(), client, opts)
}
// CreateConsumerOptsBuilder allows extensions to add additional parameters to
// the CreateConsumer request.
type CreateConsumerOptsBuilder interface {
@ -184,37 +178,27 @@ func (opts CreateConsumerOpts) ToOAuth1CreateConsumerMap() (map[string]interface
return gophercloud.BuildRequestBody(opts, "consumer")
}
// CreateConsumerWithContext creates a new Consumer.
func CreateConsumerWithContext(ctx context.Context, client *gophercloud.ServiceClient, opts CreateConsumerOptsBuilder) (r CreateConsumerResult) {
// Create creates a new Consumer.
func CreateConsumer(client *gophercloud.ServiceClient, opts CreateConsumerOptsBuilder) (r CreateConsumerResult) {
b, err := opts.ToOAuth1CreateConsumerMap()
if err != nil {
r.Err = err
return
}
resp, err := client.PostWithContext(ctx, consumersURL(client), b, &r.Body, &gophercloud.RequestOpts{
resp, err := client.Post(consumersURL(client), b, &r.Body, &gophercloud.RequestOpts{
OkCodes: []int{201},
})
_, r.Header, r.Err = gophercloud.ParseResponse(resp, err)
return
}
// CreateConsumer is a compatibility wrapper around CreateConsumerWithContext.
func CreateConsumer(client *gophercloud.ServiceClient, opts CreateConsumerOptsBuilder) (r CreateConsumerResult) {
return CreateConsumerWithContext(context.Background(), client, opts)
}
// DeleteConsumerWithContext deletes a Consumer.
func DeleteConsumerWithContext(ctx context.Context, client *gophercloud.ServiceClient, id string) (r DeleteConsumerResult) {
resp, err := client.DeleteWithContext(ctx, consumerURL(client, id), nil)
// Delete deletes a Consumer.
func DeleteConsumer(client *gophercloud.ServiceClient, id string) (r DeleteConsumerResult) {
resp, err := client.Delete(consumerURL(client, id), nil)
_, r.Header, r.Err = gophercloud.ParseResponse(resp, err)
return
}
// DeleteConsumer is a compatibility wrapper around DeleteConsumerWithContext.
func DeleteConsumer(client *gophercloud.ServiceClient, id string) (r DeleteConsumerResult) {
return DeleteConsumerWithContext(context.Background(), client, id)
}
// List enumerates Consumers.
func ListConsumers(client *gophercloud.ServiceClient) pagination.Pager {
return pagination.NewPager(client, consumersURL(client), func(r pagination.PageResult) pagination.Page {
@ -222,18 +206,13 @@ func ListConsumers(client *gophercloud.ServiceClient) pagination.Pager {
})
}
// GetConsumerWithContext retrieves details on a single Consumer by ID.
func GetConsumerWithContext(ctx context.Context, client *gophercloud.ServiceClient, id string) (r GetConsumerResult) {
resp, err := client.GetWithContext(ctx, consumerURL(client, id), &r.Body, nil)
// GetConsumer retrieves details on a single Consumer by ID.
func GetConsumer(client *gophercloud.ServiceClient, id string) (r GetConsumerResult) {
resp, err := client.Get(consumerURL(client, id), &r.Body, nil)
_, r.Header, r.Err = gophercloud.ParseResponse(resp, err)
return
}
// GetConsumer is a compatibility wrapper around GetConsumerWithContext.
func GetConsumer(client *gophercloud.ServiceClient, id string) (r GetConsumerResult) {
return GetConsumerWithContext(context.Background(), client, id)
}
// UpdateConsumerOpts provides options used to update a consumer.
type UpdateConsumerOpts struct {
// Description is the consumer description.
@ -246,25 +225,20 @@ func (opts UpdateConsumerOpts) ToOAuth1UpdateConsumerMap() (map[string]interface
return gophercloud.BuildRequestBody(opts, "consumer")
}
// UpdateConsumerWithContext updates an existing Consumer.
func UpdateConsumerWithContext(ctx context.Context, client *gophercloud.ServiceClient, id string, opts UpdateConsumerOpts) (r UpdateConsumerResult) {
// UpdateConsumer updates an existing Consumer.
func UpdateConsumer(client *gophercloud.ServiceClient, id string, opts UpdateConsumerOpts) (r UpdateConsumerResult) {
b, err := opts.ToOAuth1UpdateConsumerMap()
if err != nil {
r.Err = err
return
}
resp, err := client.PatchWithContext(ctx, consumerURL(client, id), b, &r.Body, &gophercloud.RequestOpts{
resp, err := client.Patch(consumerURL(client, id), b, &r.Body, &gophercloud.RequestOpts{
OkCodes: []int{200},
})
_, r.Header, r.Err = gophercloud.ParseResponse(resp, err)
return
}
// UpdateConsumer is a compatibility wrapper around UpdateConsumerWithContext.
func UpdateConsumer(client *gophercloud.ServiceClient, id string, opts UpdateConsumerOpts) (r UpdateConsumerResult) {
return UpdateConsumerWithContext(context.Background(), client, id, opts)
}
// RequestTokenOptsBuilder allows extensions to add additional parameters to the
// RequestToken request.
type RequestTokenOptsBuilder interface {
@ -323,15 +297,15 @@ func (opts RequestTokenOpts) ToOAuth1RequestTokenHeaders(method, u string) (map[
return h, nil
}
// RequestTokenWithContext requests an unauthorized OAuth1 Token.
func RequestTokenWithContext(ctx context.Context, client *gophercloud.ServiceClient, opts RequestTokenOptsBuilder) (r TokenResult) {
// RequestToken requests an unauthorized OAuth1 Token.
func RequestToken(client *gophercloud.ServiceClient, opts RequestTokenOptsBuilder) (r TokenResult) {
h, err := opts.ToOAuth1RequestTokenHeaders("POST", requestTokenURL(client))
if err != nil {
r.Err = err
return
}
resp, err := client.PostWithContext(ctx, requestTokenURL(client), nil, nil, &gophercloud.RequestOpts{
resp, err := client.Post(requestTokenURL(client), nil, nil, &gophercloud.RequestOpts{
MoreHeaders: h,
OkCodes: []int{201},
KeepResponseBody: true,
@ -349,11 +323,6 @@ func RequestTokenWithContext(ctx context.Context, client *gophercloud.ServiceCli
return
}
// RequestToken is a compatibility wrapper around RequestTokenWithContext.
func RequestToken(client *gophercloud.ServiceClient, opts RequestTokenOptsBuilder) (r TokenResult) {
return RequestTokenWithContext(context.Background(), client, opts)
}
// AuthorizeTokenOptsBuilder allows extensions to add additional parameters to
// the AuthorizeToken request.
type AuthorizeTokenOptsBuilder interface {
@ -382,25 +351,20 @@ func (opts AuthorizeTokenOpts) ToOAuth1AuthorizeTokenMap() (map[string]interface
return gophercloud.BuildRequestBody(opts, "")
}
// AuthorizeTokenWithContext authorizes an unauthorized consumer token.
func AuthorizeTokenWithContext(ctx context.Context, client *gophercloud.ServiceClient, id string, opts AuthorizeTokenOptsBuilder) (r AuthorizeTokenResult) {
// AuthorizeToken authorizes an unauthorized consumer token.
func AuthorizeToken(client *gophercloud.ServiceClient, id string, opts AuthorizeTokenOptsBuilder) (r AuthorizeTokenResult) {
b, err := opts.ToOAuth1AuthorizeTokenMap()
if err != nil {
r.Err = err
return
}
resp, err := client.PutWithContext(ctx, authorizeTokenURL(client, id), b, &r.Body, &gophercloud.RequestOpts{
resp, err := client.Put(authorizeTokenURL(client, id), b, &r.Body, &gophercloud.RequestOpts{
OkCodes: []int{200},
})
_, r.Header, r.Err = gophercloud.ParseResponse(resp, err)
return
}
// AuthorizeToken is a compatibility wrapper around AuthorizeTokenWithContext.
func AuthorizeToken(client *gophercloud.ServiceClient, id string, opts AuthorizeTokenOptsBuilder) (r AuthorizeTokenResult) {
return AuthorizeTokenWithContext(context.Background(), client, id, opts)
}
// CreateAccessTokenOptsBuilder allows extensions to add additional parameters
// to the CreateAccessToken request.
type CreateAccessTokenOptsBuilder interface {
@ -461,15 +425,15 @@ func (opts CreateAccessTokenOpts) ToOAuth1CreateAccessTokenHeaders(method, u str
return headers, nil
}
// CreateAccessTokenWithContext creates a new OAuth1 Access Token
func CreateAccessTokenWithContext(ctx context.Context, client *gophercloud.ServiceClient, opts CreateAccessTokenOptsBuilder) (r TokenResult) {
// CreateAccessToken creates a new OAuth1 Access Token
func CreateAccessToken(client *gophercloud.ServiceClient, opts CreateAccessTokenOptsBuilder) (r TokenResult) {
h, err := opts.ToOAuth1CreateAccessTokenHeaders("POST", createAccessTokenURL(client))
if err != nil {
r.Err = err
return
}
resp, err := client.PostWithContext(ctx, createAccessTokenURL(client), nil, nil, &gophercloud.RequestOpts{
resp, err := client.Post(createAccessTokenURL(client), nil, nil, &gophercloud.RequestOpts{
MoreHeaders: h,
OkCodes: []int{201},
KeepResponseBody: true,
@ -487,33 +451,18 @@ func CreateAccessTokenWithContext(ctx context.Context, client *gophercloud.Servi
return
}
// CreateAccessToken is a compatibility wrapper around CreateAccessTokenWithContext.
func CreateAccessToken(client *gophercloud.ServiceClient, opts CreateAccessTokenOptsBuilder) (r TokenResult) {
return CreateAccessTokenWithContext(context.Background(), client, opts)
}
// GetAccessTokenWithContext retrieves details on a single OAuth1 access token by an ID.
func GetAccessTokenWithContext(ctx context.Context, client *gophercloud.ServiceClient, userID string, id string) (r GetAccessTokenResult) {
resp, err := client.GetWithContext(ctx, userAccessTokenURL(client, userID, id), &r.Body, nil)
_, r.Header, r.Err = gophercloud.ParseResponse(resp, err)
return
}
// GetAccessToken is a compatibility wrapper around GetAccessTokenWithContext.
// GetAccessToken retrieves details on a single OAuth1 access token by an ID.
func GetAccessToken(client *gophercloud.ServiceClient, userID string, id string) (r GetAccessTokenResult) {
return GetAccessTokenWithContext(context.Background(), client, userID, id)
}
// RevokeAccessTokenWithContext revokes an OAuth1 access token.
func RevokeAccessTokenWithContext(ctx context.Context, client *gophercloud.ServiceClient, userID string, id string) (r RevokeAccessTokenResult) {
resp, err := client.DeleteWithContext(ctx, userAccessTokenURL(client, userID, id), nil)
resp, err := client.Get(userAccessTokenURL(client, userID, id), &r.Body, nil)
_, r.Header, r.Err = gophercloud.ParseResponse(resp, err)
return
}
// RevokeAccessToken is a compatibility wrapper around RevokeAccessTokenWithContext.
// RevokeAccessToken revokes an OAuth1 access token.
func RevokeAccessToken(client *gophercloud.ServiceClient, userID string, id string) (r RevokeAccessTokenResult) {
return RevokeAccessTokenWithContext(context.Background(), client, userID, id)
resp, err := client.Delete(userAccessTokenURL(client, userID, id), nil)
_, r.Header, r.Err = gophercloud.ParseResponse(resp, err)
return
}
// ListAccessTokens enumerates authorized access tokens.
@ -532,19 +481,14 @@ func ListAccessTokenRoles(client *gophercloud.ServiceClient, userID string, id s
})
}
// GetAccessTokenRoleWithContext retrieves details on a single OAuth1 access token role by
// GetAccessTokenRole retrieves details on a single OAuth1 access token role by
// an ID.
func GetAccessTokenRoleWithContext(ctx context.Context, client *gophercloud.ServiceClient, userID string, id string, roleID string) (r GetAccessTokenRoleResult) {
resp, err := client.GetWithContext(ctx, userAccessTokenRoleURL(client, userID, id, roleID), &r.Body, nil)
func GetAccessTokenRole(client *gophercloud.ServiceClient, userID string, id string, roleID string) (r GetAccessTokenRoleResult) {
resp, err := client.Get(userAccessTokenRoleURL(client, userID, id, roleID), &r.Body, nil)
_, r.Header, r.Err = gophercloud.ParseResponse(resp, err)
return
}
// GetAccessTokenRole is a compatibility wrapper around GetAccessTokenRoleWithContext.
func GetAccessTokenRole(client *gophercloud.ServiceClient, userID string, id string, roleID string) (r GetAccessTokenRoleResult) {
return GetAccessTokenRoleWithContext(context.Background(), client, userID, id, roleID)
}
// The following are small helper functions used to help build the signature.
// buildOAuth1QueryString builds a URLEncoded parameters string specific for

View file

@ -1,10 +1,6 @@
package tokens
import (
"context"
"github.com/gophercloud/gophercloud"
)
import "github.com/gophercloud/gophercloud"
// Scope allows a created token to be limited to a specific domain or project.
type Scope struct {
@ -123,9 +119,9 @@ func subjectTokenHeaders(subjectToken string) map[string]string {
}
}
// CreateWithContext authenticates and either generates a new token, or changes the Scope
// Create authenticates and either generates a new token, or changes the Scope
// of an existing token.
func CreateWithContext(ctx context.Context, c *gophercloud.ServiceClient, opts AuthOptionsBuilder) (r CreateResult) {
func Create(c *gophercloud.ServiceClient, opts AuthOptionsBuilder) (r CreateResult) {
scope, err := opts.ToTokenV3ScopeMap()
if err != nil {
r.Err = err
@ -138,21 +134,16 @@ func CreateWithContext(ctx context.Context, c *gophercloud.ServiceClient, opts A
return
}
resp, err := c.PostWithContext(ctx, tokenURL(c), b, &r.Body, &gophercloud.RequestOpts{
resp, err := c.Post(tokenURL(c), b, &r.Body, &gophercloud.RequestOpts{
OmitHeaders: []string{"X-Auth-Token"},
})
_, r.Header, r.Err = gophercloud.ParseResponse(resp, err)
return
}
// Create is a compatibility wrapper around CreateWithContext
func Create(c *gophercloud.ServiceClient, opts AuthOptionsBuilder) (r CreateResult) {
return CreateWithContext(context.Background(), c, opts)
}
// GetGetWithContext validates and retrieves information about another token.
func GetWithContext(ctx context.Context, c *gophercloud.ServiceClient, token string) (r GetResult) {
resp, err := c.GetWithContext(ctx, tokenURL(c), &r.Body, &gophercloud.RequestOpts{
// Get validates and retrieves information about another token.
func Get(c *gophercloud.ServiceClient, token string) (r GetResult) {
resp, err := c.Get(tokenURL(c), &r.Body, &gophercloud.RequestOpts{
MoreHeaders: subjectTokenHeaders(token),
OkCodes: []int{200, 203},
})
@ -160,14 +151,9 @@ func GetWithContext(ctx context.Context, c *gophercloud.ServiceClient, token str
return
}
// Get is a compatibility wrapper around GetWithContext
func Get(c *gophercloud.ServiceClient, token string) (r GetResult) {
return GetWithContext(context.Background(), c, token)
}
// ValidateWithContext determines if a specified token is valid or not.
func ValidateWithContext(ctx context.Context, c *gophercloud.ServiceClient, token string) (bool, error) {
resp, err := c.HeadWithContext(ctx, tokenURL(c), &gophercloud.RequestOpts{
// Validate determines if a specified token is valid or not.
func Validate(c *gophercloud.ServiceClient, token string) (bool, error) {
resp, err := c.Head(tokenURL(c), &gophercloud.RequestOpts{
MoreHeaders: subjectTokenHeaders(token),
OkCodes: []int{200, 204, 404},
})
@ -178,21 +164,11 @@ func ValidateWithContext(ctx context.Context, c *gophercloud.ServiceClient, toke
return resp.StatusCode == 200 || resp.StatusCode == 204, nil
}
// Validate is a compatibility wrapper around ValidateWithContext
func Validate(c *gophercloud.ServiceClient, token string) (bool, error) {
return ValidateWithContext(context.Background(), c, token)
}
// RevokeWithContext immediately makes specified token invalid.
func RevokeWithContext(ctx context.Context, c *gophercloud.ServiceClient, token string) (r RevokeResult) {
resp, err := c.DeleteWithContext(ctx, tokenURL(c), &gophercloud.RequestOpts{
// Revoke immediately makes specified token invalid.
func Revoke(c *gophercloud.ServiceClient, token string) (r RevokeResult) {
resp, err := c.Delete(tokenURL(c), &gophercloud.RequestOpts{
MoreHeaders: subjectTokenHeaders(token),
})
_, r.Header, r.Err = gophercloud.ParseResponse(resp, err)
return
}
// Revoke is a compatibility wrapper around RevokeWithContext
func Revoke(c *gophercloud.ServiceClient, token string) (r RevokeResult) {
return RevokeWithContext(context.Background(), c, token)
}