Skip to content

Commit

Permalink
timeout is now passed to operation wait (#3082)
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 and emilymye committed Feb 22, 2019
1 parent 9b8f726 commit 82f0251
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
4 changes: 2 additions & 2 deletions google/cloudfunctions_operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ func (w *CloudFunctionsOperationWaiter) QueryOp() (interface{}, error) {
return w.Service.Operations.Get(w.Op.Name).Do()
}

func cloudFunctionsOperationWait(service *cloudfunctions.Service, op *cloudfunctions.Operation, activity string) error {
func cloudFunctionsOperationWait(service *cloudfunctions.Service, op *cloudfunctions.Operation, activity string, timeoutMin int) error {
w := &CloudFunctionsOperationWaiter{
Service: service,
}
if err := w.SetOp(op); err != nil {
return err
}
return OperationWait(w, activity, 4)
return OperationWait(w, activity, timeoutMin)
}
10 changes: 6 additions & 4 deletions google/resource_cloudfunctions_function.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,8 @@ func resourceCloudFunctionsCreate(d *schema.ResourceData, meta interface{}) erro
// Name of function should be unique
d.SetId(cloudFuncId.terraformId())

err = cloudFunctionsOperationWait(config.clientCloudFunctions, op, "Creating CloudFunctions Function")
err = cloudFunctionsOperationWait(config.clientCloudFunctions, op, "Creating CloudFunctions Function",
int(d.Timeout(schema.TimeoutCreate).Minutes()))
if err != nil {
return err
}
Expand Down Expand Up @@ -522,8 +523,8 @@ func resourceCloudFunctionsUpdate(d *schema.ResourceData, meta interface{}) erro
return fmt.Errorf("Error while updating cloudfunction configuration: %s", err)
}

err = cloudFunctionsOperationWait(config.clientCloudFunctions, op,
"Updating CloudFunctions Function")
err = cloudFunctionsOperationWait(config.clientCloudFunctions, op, "Updating CloudFunctions Function",
int(d.Timeout(schema.TimeoutUpdate).Minutes()))
if err != nil {
return err
}
Expand All @@ -545,7 +546,8 @@ func resourceCloudFunctionsDestroy(d *schema.ResourceData, meta interface{}) err
if err != nil {
return err
}
err = cloudFunctionsOperationWait(config.clientCloudFunctions, op, "Deleting CloudFunctions Function")
err = cloudFunctionsOperationWait(config.clientCloudFunctions, op, "Deleting CloudFunctions Function",
int(d.Timeout(schema.TimeoutDelete).Minutes()))
if err != nil {
return err
}
Expand Down
9 changes: 9 additions & 0 deletions website/docs/r/cloudfunctions_function.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,15 @@ exported:

* `region` - Region of function. Currently can be only "us-central1". If it is not provided, the provider region is used.

## Timeouts

This resource provides the following
[Timeouts](/docs/configuration/resources.html#timeouts) configuration options:

- `create` - Default is 5 minutes.
- `update` - Default is 5 minutes.
- `delete` - Default is 5 minutes.

## Import

Functions can be imported using the `name`, e.g.
Expand Down

0 comments on commit 82f0251

Please sign in to comment.