Skip to content

Commit

Permalink
Make compute subnetwork purpose computed
Browse files Browse the repository at this point in the history
Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
emilymye authored and modular-magician committed Sep 9, 2019
1 parent f160b35 commit e6bda06
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 46 deletions.
1 change: 1 addition & 0 deletions google/resource_sql_database_instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"

sqladmin "google.golang.org/api/sqladmin/v1beta4"
)

Expand Down
13 changes: 1 addition & 12 deletions google/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ func retryTimeDuration(retryFunc func() error, duration time.Duration, errorRetr
if err == nil {
return nil
}
for _, e := range getAllTypes(err, &googleapi.Error{}, &url.Error{}) {
for _, e := range errwrap.GetAllType(err, &googleapi.Error{}) {
if isRetryableError(e, errorRetryPredicates) {
return resource.RetryableError(e)
}
Expand All @@ -370,17 +370,6 @@ func retryTimeDuration(retryFunc func() error, duration time.Duration, errorRetr
})
}

func getAllTypes(err error, args ...interface{}) []error {
var result []error
for _, v := range args {
subResult := errwrap.GetAllType(err, v)
if subResult != nil {
result = append(result, subResult...)
}
}
return result
}

func isRetryableError(err error, retryPredicates []func(e error) (bool, string)) bool {

// These operations are always hitting googleapis.com - they should rarely
Expand Down
34 changes: 0 additions & 34 deletions google/utils_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package google

import (
"net/url"
"reflect"
"strings"
"testing"
Expand Down Expand Up @@ -529,36 +528,3 @@ func TestRetryTimeDuration_noretry(t *testing.T) {
t.Errorf("expected error function to be called exactly once, but was called %d times", i)
}
}

type TimeoutError struct {
timeout bool
}

func (e *TimeoutError) Timeout() bool {
return e.timeout
}

func (e *TimeoutError) Error() string {
return "timeout error"
}

func TestRetryTimeDuration_URLTimeoutsShouldRetry(t *testing.T) {
runCount := 0
retryFunc := func() error {
runCount++
if runCount == 1 {
return &url.Error{
Err: &TimeoutError{timeout: true},
}
}
return nil
}
err := retryTimeDuration(retryFunc, 1*time.Minute)
if err != nil {
t.Errorf("unexpected error: got '%v' want 'nil'", err)
}
expectedRunCount := 2
if runCount != expectedRunCount {
t.Errorf("expected the retryFunc to be called %v time(s), instead was called %v time(s)", expectedRunCount, runCount)
}
}

0 comments on commit e6bda06

Please sign in to comment.