Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UserProjectOverride for ContainerOperationWaiter #9379

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/4874.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
container: Added `user_project_override` support to the ContainerOperationWaiter used by `google_container_cluster`
```
28 changes: 17 additions & 11 deletions google/container_operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)

Expand All @@ -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 {
Expand Down
4 changes: 4 additions & 0 deletions website/docs/r/container_cluster.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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).