diff --git a/.changelog/4874.txt b/.changelog/4874.txt new file mode 100644 index 00000000000..0eeadd79722 --- /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/container_operation.go b/google/container_operation.go index 46e413deb11..df62c1d4ee8 100644 --- a/google/container_operation.go +++ b/google/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/website/docs/r/container_cluster.html.markdown b/website/docs/r/container_cluster.html.markdown index 3ccff47832b..2b794c84159 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).