upgrade google.golang.org/api to v0.45.0

Signed-off-by: pacoxu <paco.xu@daocloud.io>
This commit is contained in:
pacoxu
2021-07-02 11:34:32 +08:00
committed by paco
parent 18d583653c
commit 2926b4572e
67 changed files with 101529 additions and 14704 deletions

View File

@@ -12,6 +12,7 @@ import (
"golang.org/x/oauth2"
"golang.org/x/oauth2/google"
"google.golang.org/api/internal/impersonate"
"google.golang.org/grpc"
)
@@ -22,6 +23,7 @@ type DialSettings struct {
DefaultEndpoint string
DefaultMTLSEndpoint string
Scopes []string
DefaultScopes []string
TokenSource oauth2.TokenSource
Credentials *google.Credentials
CredentialsFile string // if set, Token Source is ignored.
@@ -29,6 +31,7 @@ type DialSettings struct {
UserAgent string
APIKey string
Audiences []string
DefaultAudience string
HTTPClient *http.Client
GRPCDialOpts []grpc.DialOption
GRPCConn *grpc.ClientConn
@@ -39,6 +42,8 @@ type DialSettings struct {
ClientCertSource func(*tls.CertificateRequestInfo) (*tls.Certificate, error)
CustomClaims map[string]interface{}
SkipValidation bool
ImpersonationConfig *impersonate.Config
EnableDirectPath bool
// Google API system parameters. For more information please read:
// https://cloud.google.com/apis/docs/system-parameters
@@ -46,6 +51,15 @@ type DialSettings struct {
RequestReason string
}
// GetScopes returns the user-provided scopes, if set, or else falls back to the
// default scopes.
func (ds *DialSettings) GetScopes() []string {
if len(ds.Scopes) > 0 {
return ds.Scopes
}
return ds.DefaultScopes
}
// Validate reports an error if ds is invalid.
func (ds *DialSettings) Validate() error {
if ds.SkipValidation {
@@ -105,6 +119,8 @@ func (ds *DialSettings) Validate() error {
if ds.ClientCertSource != nil && (ds.GRPCConn != nil || ds.GRPCConnPool != nil || ds.GRPCConnPoolSize != 0 || ds.GRPCDialOpts != nil) {
return errors.New("WithClientCertSource is currently only supported for HTTP. gRPC settings are incompatible")
}
if ds.ImpersonationConfig != nil && len(ds.ImpersonationConfig.Scopes) == 0 && len(ds.Scopes) == 0 {
return errors.New("WithImpersonatedCredentials requires scopes being provided")
}
return nil
}