...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package transport
18
19 import (
20 "fmt"
21
22 "cloud.google.com/go/auth/credentials"
23 )
24
25
26
27 func CloneDetectOptions(oldDo *credentials.DetectOptions) *credentials.DetectOptions {
28 if oldDo == nil {
29
30
31
32 return &credentials.DetectOptions{}
33 }
34 newDo := &credentials.DetectOptions{
35
36 Audience: oldDo.Audience,
37 Subject: oldDo.Subject,
38 EarlyTokenRefresh: oldDo.EarlyTokenRefresh,
39 TokenURL: oldDo.TokenURL,
40 STSAudience: oldDo.STSAudience,
41 CredentialsFile: oldDo.CredentialsFile,
42 UseSelfSignedJWT: oldDo.UseSelfSignedJWT,
43 UniverseDomain: oldDo.UniverseDomain,
44
45
46
47 Client: oldDo.Client,
48 AuthHandlerOptions: oldDo.AuthHandlerOptions,
49 }
50
51
52 if oldDo.CredentialsJSON != nil {
53 newDo.CredentialsJSON = make([]byte, len(oldDo.CredentialsJSON))
54 copy(newDo.CredentialsJSON, oldDo.CredentialsJSON)
55 }
56 if oldDo.Scopes != nil {
57 newDo.Scopes = make([]string, len(oldDo.Scopes))
58 copy(newDo.Scopes, oldDo.Scopes)
59 }
60
61 return newDo
62 }
63
64
65
66 func ValidateUniverseDomain(clientUniverseDomain, credentialsUniverseDomain string) error {
67 if clientUniverseDomain != credentialsUniverseDomain {
68 return fmt.Errorf(
69 "the configured universe domain (%q) does not match the universe "+
70 "domain found in the credentials (%q). If you haven't configured "+
71 "the universe domain explicitly, \"googleapis.com\" is the default",
72 clientUniverseDomain,
73 credentialsUniverseDomain)
74 }
75 return nil
76 }
77
View as plain text