Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove build tags for go versions < 1.15 #1461

Merged
merged 2 commits into from Mar 10, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 0 additions & 24 deletions option/credentials_go19.go

This file was deleted.

23 changes: 0 additions & 23 deletions option/credentials_notgo19.go

This file was deleted.

12 changes: 12 additions & 0 deletions option/option.go
Expand Up @@ -10,6 +10,7 @@ import (
"net/http"

"golang.org/x/oauth2"
"golang.org/x/oauth2/google"
"google.golang.org/api/internal"
"google.golang.org/api/internal/impersonate"
"google.golang.org/grpc"
Expand Down Expand Up @@ -328,3 +329,14 @@ func (i impersonateServiceAccount) Apply(o *internal.DialSettings) {
o.ImpersonationConfig.Delegates = make([]string, len(i.delegates))
copy(o.ImpersonationConfig.Delegates, i.delegates)
}

type withCreds google.Credentials

func (w *withCreds) Apply(o *internal.DialSettings) {
o.Credentials = (*google.Credentials)(w)
}

// WithCredentials returns a ClientOption that authenticates API calls.
func WithCredentials(creds *google.Credentials) ClientOption {
return (*withCreds)(creds)
}
12 changes: 12 additions & 0 deletions transport/dial.go
Expand Up @@ -8,8 +8,10 @@ import (
"context"
"net/http"

"golang.org/x/oauth2/google"
"google.golang.org/grpc"

"google.golang.org/api/internal"
"google.golang.org/api/option"
gtransport "google.golang.org/api/transport/grpc"
htransport "google.golang.org/api/transport/http"
Expand All @@ -34,3 +36,13 @@ func DialGRPC(ctx context.Context, opts ...option.ClientOption) (*grpc.ClientCon
func DialGRPCInsecure(ctx context.Context, opts ...option.ClientOption) (*grpc.ClientConn, error) {
return gtransport.DialInsecure(ctx, opts...)
}

// Creds constructs a google.Credentials from the information in the options,
// or obtains the default credentials in the same way as google.FindDefaultCredentials.
func Creds(ctx context.Context, opts ...option.ClientOption) (*google.Credentials, error) {
var ds internal.DialSettings
for _, opt := range opts {
opt.Apply(&ds)
}
return internal.Creds(ctx, &ds)
}
26 changes: 0 additions & 26 deletions transport/go19.go

This file was deleted.

21 changes: 0 additions & 21 deletions transport/http/default_transport_go113.go

This file was deleted.

16 changes: 0 additions & 16 deletions transport/http/default_transport_not_go113.go

This file was deleted.

11 changes: 11 additions & 0 deletions transport/http/dial.go
Expand Up @@ -210,3 +210,14 @@ func addOCTransport(trans http.RoundTripper, settings *internal.DialSettings) ht
Propagation: &propagation.HTTPFormat{},
}
}

// clonedTransport returns the given RoundTripper as a cloned *http.Transport.
// It returns nil if the RoundTripper can't be cloned or coerced to
// *http.Transport.
func clonedTransport(rt http.RoundTripper) *http.Transport {
t, ok := rt.(*http.Transport)
if !ok {
return nil
}
return t.Clone()
}
26 changes: 0 additions & 26 deletions transport/not_go19.go

This file was deleted.