Skip to content

Commit

Permalink
update comments in accordance with code review
Browse files Browse the repository at this point in the history
  • Loading branch information
ScottSuarez committed Dec 17, 2024
1 parent ba577fe commit 816af01
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions mmv1/third_party/terraform/transport/config.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -438,9 +438,10 @@ func (c *Config) LoadAndValidate(ctx context.Context) error {
cleanCtx := context.WithValue(ctx, oauth2.HTTPClient, cleanhttp.DefaultClient())
clientOptions := []option.ClientOption{option.WithTokenSource(tokenSource)}

// 'X-Goog-User-Project' gets set by a transport layer within transport.NewHTTPClient
// setting explicitly here to override the setting of it by underlying utility function.
// b/360405077#comment8
// The client libraries allow setting the GOOGLE_CLOUD_QUOTA_PROJECT environment variable
// directly, which unintentionally takes precedence over provider settings. Ensure that
// provider settings take precedence by applying to the client library's client directly
// b/360405077#comment8 - go/tpg-issue/17882
if c.UserProjectOverride && c.BillingProject != "" {
quotaProject := c.BillingProject
clientOptions = append(clientOptions, option.WithQuotaProject(quotaProject))
Expand Down Expand Up @@ -476,12 +477,10 @@ func (c *Config) LoadAndValidate(ctx context.Context) error {

// Ensure $userProject is set for all HTTP requests using the client if specified by the provider config
// See https://cloud.google.com/apis/docs/system-parameters
// We explicitly set this header for logging visibility, even though
// option.WithQuotaProject will automatically set it in the client.
// This duplicate setting ensures the header appears in our request logs
// since our logging transport sits on top of the Google client library's
// internal transport that would also sets this header.
// option.WithQuotaProject will automatically set it in the client
// option.WithQuotaProject automatically sets the quota project in the client.
// However, this setting won't appear in our request logs since our logging
// transport sits above the Google client's internal transport. To ensure
// visibility in debug logging, we explicitly set the quota project here as well.
if c.UserProjectOverride && c.BillingProject != "" {
headerTransport.Set("X-Goog-User-Project", c.BillingProject)
}
Expand Down

0 comments on commit 816af01

Please sign in to comment.