Skip to content

Commit

Permalink
fix(auth): use default client for universe metadata lookup (googleapi…
Browse files Browse the repository at this point in the history
…s#10551)

When this code was first introduced we did not have the context methods in the metadata package so we set the timeout on the client. Now that we do we should use context to set the timeout and use the default client the metadata package provides.

Fixes: googleapis#10544
  • Loading branch information
codyoss authored Jul 15, 2024
1 parent 8cf89a3 commit d9046fd
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions auth/internal/internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,9 @@ func (c *ComputeUniverseDomainProvider) GetProperty(ctx context.Context) (string

// httpGetMetadataUniverseDomain is a package var for unit test substitution.
var httpGetMetadataUniverseDomain = func(ctx context.Context) (string, error) {
client := metadata.NewClient(&http.Client{Timeout: time.Second})
return client.GetWithContext(ctx, "universe/universe_domain")
ctx, cancel := context.WithTimeout(ctx, 1*time.Second)
defer cancel()
return metadata.GetWithContext(ctx, "universe/universe_domain")
}

func getMetadataUniverseDomain(ctx context.Context) (string, error) {
Expand Down

0 comments on commit d9046fd

Please sign in to comment.