diff --git a/.changelog/4874.txt b/.changelog/4874.txt new file mode 100644 index 0000000000..0eeadd7972 --- /dev/null +++ b/.changelog/4874.txt @@ -0,0 +1,3 @@ +```release-note:bug +container: Added `user_project_override` support to the ContainerOperationWaiter used by `google_container_cluster` +``` diff --git a/google-beta/container_operation.go b/google-beta/container_operation.go index 46e413deb1..df62c1d4ee 100644 --- a/google-beta/container_operation.go +++ b/google-beta/container_operation.go @@ -11,11 +11,12 @@ import ( ) type ContainerOperationWaiter struct { - Service *container.Service - Context context.Context - Op *container.Operation - Project string - Location string + Service *container.Service + Context context.Context + Op *container.Operation + Project string + Location string + UserProjectOverride bool } func (w *ContainerOperationWaiter) State() string { @@ -75,7 +76,11 @@ func (w *ContainerOperationWaiter) QueryOp() (interface{}, error) { // default must be here to keep the previous case from blocking } err := retryTimeDuration(func() (opErr error) { - op, opErr = w.Service.Projects.Locations.Operations.Get(name).Do() + opGetCall := w.Service.Projects.Locations.Operations.Get(name) + if w.UserProjectOverride { + opGetCall.Header().Add("X-Goog-User-Project", w.Project) + } + op, opErr = opGetCall.Do() return opErr }, DefaultRequestTimeout) @@ -99,11 +104,12 @@ func (w *ContainerOperationWaiter) TargetStates() []string { func containerOperationWait(config *Config, op *container.Operation, project, location, activity, userAgent string, timeout time.Duration) error { w := &ContainerOperationWaiter{ - Service: config.NewContainerBetaClient(userAgent), - Context: config.context, - Op: op, - Project: project, - Location: location, + Service: config.NewContainerBetaClient(userAgent), + Context: config.context, + Op: op, + Project: project, + Location: location, + UserProjectOverride: config.UserProjectOverride, } if err := w.SetOp(op); err != nil { diff --git a/google-beta/resource_gke_hub_feature_membership_test.go b/google-beta/resource_gke_hub_feature_membership_test.go index 9e1f2ea64d..32fa84c196 100644 --- a/google-beta/resource_gke_hub_feature_membership_test.go +++ b/google-beta/resource_gke_hub_feature_membership_test.go @@ -5,7 +5,7 @@ import ( "fmt" "testing" - "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" + dcl "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" gkehub "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/gkehub/beta" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" diff --git a/website/docs/r/container_cluster.html.markdown b/website/docs/r/container_cluster.html.markdown index 3ccff47832..2b794c8415 100644 --- a/website/docs/r/container_cluster.html.markdown +++ b/website/docs/r/container_cluster.html.markdown @@ -947,3 +947,7 @@ For example, the following fields will show diffs if set in config: - `min_master_version` - `remove_default_node_pool` + +## User Project Overrides + +This resource supports [User Project Overrides](https://www.terraform.io/docs/providers/google/guides/provider_reference.html#user_project_override).