Skip to content

Commit

Permalink
feat(transport): add universe domain support
Browse files Browse the repository at this point in the history
  • Loading branch information
quartzmo committed Jan 18, 2024
1 parent 72a8ffd commit 348f707
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions transport/http/dial.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"context"
"crypto/tls"
"errors"
"fmt"
"net"
"net/http"
"time"
Expand Down Expand Up @@ -88,6 +89,13 @@ func newTransport(ctx context.Context, base http.RoundTripper, settings *interna
if err != nil {
return nil, err
}
credsUniverseDomain, err := creds.GetUniverseDomain()
if err != nil {
return nil, err
}
if settings.GetUniverseDomain() != credsUniverseDomain {
return nil, errUniverseNotMatch(settings.GetUniverseDomain(), credsUniverseDomain)
}
paramTransport.quotaProject = internal.GetQuotaProject(creds, settings.QuotaProject)
ts := creds.TokenSource
if settings.ImpersonationConfig == nil && settings.TokenSource != nil {
Expand All @@ -101,6 +109,15 @@ func newTransport(ctx context.Context, base http.RoundTripper, settings *interna
return trans, nil
}

func errUniverseNotMatch(settingsUD, credsUD string) error {
return fmt.Errorf(
"the configured universe domain (%s) does not match the universe "+
"domain found in the credentials (%s). If you haven't configured "+
"WithUniverseDomain explicitly, googleapis.com is the default",
settingsUD,
credsUD)
}

func newSettings(opts []option.ClientOption) (*internal.DialSettings, error) {
var o internal.DialSettings
for _, opt := range opts {
Expand Down

0 comments on commit 348f707

Please sign in to comment.