terraform-provider-google/google/spanner_instance_operation.go
The Magician cf489d4909 Adding nil guards to the wait operations (#2936)
<!-- This change is generated by MagicModules. -->
/cc @chrisst
2019-01-25 13:03:43 -08:00

34 lines
811 B
Go

package google
import (
"fmt"
"google.golang.org/api/spanner/v1"
)
type SpannerInstanceOperationWaiter struct {
Service *spanner.Service
CommonOperationWaiter
}
func (w *SpannerInstanceOperationWaiter) QueryOp() (interface{}, error) {
if w == nil {
return nil, fmt.Errorf("Cannot query operation, it's unset or nil.")
}
return w.Service.Projects.Instances.Operations.Get(w.Op.Name).Do()
}
func spannerOperationWaitTime(spanner *spanner.Service, op *spanner.Operation, _ string, activity string, timeoutMinutes int) error {
if op.Name == "" {
// This was a synchronous call - there is no operation to wait for.
return nil
}
w := &SpannerInstanceOperationWaiter{
Service: spanner,
}
if err := w.SetOp(op); err != nil {
return err
}
return OperationWait(w, activity, timeoutMinutes)
}