Skip to content

Commit

Permalink
Send billing_project for every request when set (#5086) (#769)
Browse files Browse the repository at this point in the history
Signed-off-by: Modular Magician <magic-modules@google.com>
  • Loading branch information
modular-magician authored Aug 18, 2021
1 parent 4ec015b commit 0c123a9
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions google/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ func (c *Config) LoadAndValidate(ctx context.Context) error {
if err != nil {
return err
}

// Userinfo is fetched before request logging is enabled to reduce additional noise.
err = c.logGoogleIdentities()
if err != nil {
Expand All @@ -390,6 +391,12 @@ func (c *Config) LoadAndValidate(ctx context.Context) error {
headerTransport.Set("X-Goog-Request-Reason", c.RequestReason)
}

// 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
if c.UserProjectOverride && c.BillingProject != "" {
headerTransport.Set("X-Goog-User-Project", c.BillingProject)
}

// Set final transport value.
client.Transport = headerTransport

Expand Down

0 comments on commit 0c123a9

Please sign in to comment.