mirror of
https://github.com/distribution/distribution.git
synced 2025-09-16 23:29:30 +00:00
Otel tracing MVP: vendor changes
Signed-off-by: gotgelf <gotgelf@gmail.com>
This commit is contained in:
24
vendor/google.golang.org/api/transport/grpc/dial.go
generated
vendored
24
vendor/google.golang.org/api/transport/grpc/dial.go
generated
vendored
@@ -9,7 +9,6 @@ package grpc
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"errors"
|
||||
"log"
|
||||
"net"
|
||||
@@ -22,7 +21,6 @@ import (
|
||||
"google.golang.org/api/internal"
|
||||
"google.golang.org/api/option"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials"
|
||||
grpcgoogle "google.golang.org/grpc/credentials/google"
|
||||
grpcinsecure "google.golang.org/grpc/credentials/insecure"
|
||||
"google.golang.org/grpc/credentials/oauth"
|
||||
@@ -122,18 +120,13 @@ func dial(ctx context.Context, insecure bool, o *internal.DialSettings) (*grpc.C
|
||||
if o.GRPCConn != nil {
|
||||
return o.GRPCConn, nil
|
||||
}
|
||||
clientCertSource, endpoint, err := internal.GetClientCertificateSourceAndEndpoint(o)
|
||||
transportCreds, endpoint, err := internal.GetGRPCTransportConfigAndEndpoint(o)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var transportCreds credentials.TransportCredentials
|
||||
if insecure {
|
||||
transportCreds = grpcinsecure.NewCredentials()
|
||||
} else {
|
||||
transportCreds = credentials.NewTLS(&tls.Config{
|
||||
GetClientCertificate: clientCertSource,
|
||||
})
|
||||
}
|
||||
|
||||
// Initialize gRPC dial options with transport-level security options.
|
||||
@@ -171,7 +164,7 @@ func dial(ctx context.Context, insecure bool, o *internal.DialSettings) (*grpc.C
|
||||
grpcOpts = append(grpcOpts, timeoutDialerOption)
|
||||
}
|
||||
// Check if google-c2p resolver is enabled for DirectPath
|
||||
if strings.EqualFold(os.Getenv(enableDirectPathXds), "true") {
|
||||
if isDirectPathXdsUsed(o) {
|
||||
// google-c2p resolver target must not have a port number
|
||||
if addr, _, err := net.SplitHostPort(endpoint); err == nil {
|
||||
endpoint = "google-c2p:///" + addr
|
||||
@@ -258,6 +251,19 @@ func isDirectPathEnabled(endpoint string, o *internal.DialSettings) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func isDirectPathXdsUsed(o *internal.DialSettings) bool {
|
||||
// Method 1: Enable DirectPath xDS by env;
|
||||
if strings.EqualFold(os.Getenv(enableDirectPathXds), "true") {
|
||||
return true
|
||||
}
|
||||
// Method 2: Enable DirectPath xDS by option;
|
||||
if o.EnableDirectPathXds {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
|
||||
}
|
||||
|
||||
func isTokenSourceDirectPathCompatible(ts oauth2.TokenSource, o *internal.DialSettings) bool {
|
||||
if ts == nil {
|
||||
return false
|
||||
|
11
vendor/google.golang.org/api/transport/http/dial.go
generated
vendored
11
vendor/google.golang.org/api/transport/http/dial.go
generated
vendored
@@ -33,7 +33,7 @@ func NewClient(ctx context.Context, opts ...option.ClientOption) (*http.Client,
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
clientCertSource, endpoint, err := internal.GetClientCertificateSourceAndEndpoint(settings)
|
||||
clientCertSource, dialTLSContext, endpoint, err := internal.GetHTTPTransportConfigAndEndpoint(settings)
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
@@ -41,7 +41,8 @@ func NewClient(ctx context.Context, opts ...option.ClientOption) (*http.Client,
|
||||
if settings.HTTPClient != nil {
|
||||
return settings.HTTPClient, endpoint, nil
|
||||
}
|
||||
trans, err := newTransport(ctx, defaultBaseTransport(ctx, clientCertSource), settings)
|
||||
|
||||
trans, err := newTransport(ctx, defaultBaseTransport(ctx, clientCertSource, dialTLSContext), settings)
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
@@ -152,7 +153,7 @@ var appengineUrlfetchHook func(context.Context) http.RoundTripper
|
||||
// Otherwise, use a default transport, taking most defaults from
|
||||
// http.DefaultTransport.
|
||||
// If TLSCertificate is available, set TLSClientConfig as well.
|
||||
func defaultBaseTransport(ctx context.Context, clientCertSource cert.Source) http.RoundTripper {
|
||||
func defaultBaseTransport(ctx context.Context, clientCertSource cert.Source, dialTLSContext func(context.Context, string, string) (net.Conn, error)) http.RoundTripper {
|
||||
if appengineUrlfetchHook != nil {
|
||||
return appengineUrlfetchHook(ctx)
|
||||
}
|
||||
@@ -171,6 +172,10 @@ func defaultBaseTransport(ctx context.Context, clientCertSource cert.Source) htt
|
||||
GetClientCertificate: clientCertSource,
|
||||
}
|
||||
}
|
||||
if dialTLSContext != nil {
|
||||
// If DialTLSContext is set, TLSClientConfig wil be ignored
|
||||
trans.DialTLSContext = dialTLSContext
|
||||
}
|
||||
|
||||
configureHTTP2(trans)
|
||||
|
||||
|
Reference in New Issue
Block a user