Skip to content

Commit 26b2e0d

Browse files
committed
gcp: Use CredentialsFromJSONWithTypeAndParams for universe domain support
Update GCP credential loading to use CredentialsFromJSONWithTypeAndParams and FindDefaultCredentialsWithParams instead of the basic variants. This ensures that the universe domain specified in the credentials JSON is automatically applied when creating GCP API clients. The universe domain is required for sovereign cloud installations to ensure API calls are directed to the correct endpoints.
1 parent 7643377 commit 26b2e0d

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

pkg/asset/installconfig/gcp/session.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,10 @@ type contentLoader struct {
182182
}
183183

184184
func (f *contentLoader) Load(ctx context.Context) (*googleoauth.Credentials, error) {
185-
return googleoauth.CredentialsFromJSON(ctx, []byte(f.content), compute.CloudPlatformScope)
185+
// Use CredentialsFromJSONWithParams to ensure universe domain from credentials is applied
186+
return googleoauth.CredentialsFromJSONWithParams(ctx, []byte(f.content), googleoauth.CredentialsParams{
187+
Scopes: []string{compute.CloudPlatformScope},
188+
})
186189
}
187190

188191
func (f *contentLoader) String() string {
@@ -196,7 +199,10 @@ func (f *contentLoader) Content() string {
196199
type cliLoader struct{}
197200

198201
func (c *cliLoader) Load(ctx context.Context) (*googleoauth.Credentials, error) {
199-
return googleoauth.FindDefaultCredentials(ctx, compute.CloudPlatformScope)
202+
// Use FindDefaultCredentialsWithParams to ensure universe domain from credentials is applied
203+
return googleoauth.FindDefaultCredentialsWithParams(ctx, googleoauth.CredentialsParams{
204+
Scopes: []string{compute.CloudPlatformScope},
205+
})
200206
}
201207

202208
func (c *cliLoader) String() string {

0 commit comments

Comments
 (0)