@@ -17,7 +17,6 @@ import (
17
17
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
18
18
"github.com/scaleway/scaleway-sdk-go/namegenerator"
19
19
"github.com/scaleway/scaleway-sdk-go/scw"
20
- "golang.org/x/xerrors"
21
20
)
22
21
23
22
// DefaultWaitRetryInterval is used to set the retry interval to 0 during acceptance tests
@@ -42,7 +41,7 @@ func newRegionalID(region scw.Region, id string) RegionalID {
42
41
43
42
func expandRegionalID (id interface {}) RegionalID {
44
43
regionalID := RegionalID {}
45
- tab := strings .SplitN (id .(string ), "/" , - 1 )
44
+ tab := strings .Split (id .(string ), "/" )
46
45
if len (tab ) != 2 {
47
46
regionalID .ID = id .(string )
48
47
} else {
@@ -73,7 +72,7 @@ func newZonedID(zone scw.Zone, id string) ZonedID {
73
72
74
73
func expandZonedID (id interface {}) ZonedID {
75
74
zonedID := ZonedID {}
76
- tab := strings .SplitN (id .(string ), "/" , - 1 )
75
+ tab := strings .Split (id .(string ), "/" )
77
76
if len (tab ) != 2 {
78
77
zonedID .ID = id .(string )
79
78
} else {
@@ -86,8 +85,8 @@ func expandZonedID(id interface{}) ZonedID {
86
85
}
87
86
88
87
// parseLocalizedID parses a localizedID and extracts the resource locality and id.
89
- func parseLocalizedID (localizedID string ) (locality string , ID string , err error ) {
90
- tab := strings .SplitN (localizedID , "/" , - 1 )
88
+ func parseLocalizedID (localizedID string ) (locality string , id string , err error ) {
89
+ tab := strings .Split (localizedID , "/" )
91
90
if len (tab ) != 2 {
92
91
return "" , localizedID , fmt .Errorf ("cant parse localized id: %s" , localizedID )
93
92
}
@@ -96,7 +95,7 @@ func parseLocalizedID(localizedID string) (locality string, ID string, err error
96
95
97
96
// parseLocalizedNestedID parses a localizedNestedID and extracts the resource locality, the inner and outer id.
98
97
func parseLocalizedNestedID (localizedID string ) (locality string , innerID , outerID string , err error ) {
99
- tab := strings .SplitN (localizedID , "/" , - 1 )
98
+ tab := strings .Split (localizedID , "/" )
100
99
if len (tab ) != 3 {
101
100
return "" , "" , localizedID , fmt .Errorf ("cant parse localized id: %s" , localizedID )
102
101
}
@@ -217,7 +216,7 @@ func isHTTPCodeError(err error, statusCode int) bool {
217
216
}
218
217
219
218
responseError := & scw.ResponseError {}
220
- if xerrors .As (err , & responseError ) && responseError .StatusCode == statusCode {
219
+ if errors .As (err , & responseError ) && responseError .StatusCode == statusCode {
221
220
return true
222
221
}
223
222
return false
@@ -226,25 +225,25 @@ func isHTTPCodeError(err error, statusCode int) bool {
226
225
// is404Error returns true if err is an HTTP 404 error
227
226
func is404Error (err error ) bool {
228
227
notFoundError := & scw.ResourceNotFoundError {}
229
- return isHTTPCodeError (err , http .StatusNotFound ) || xerrors .As (err , & notFoundError )
228
+ return isHTTPCodeError (err , http .StatusNotFound ) || errors .As (err , & notFoundError )
230
229
}
231
230
232
231
func is412Error (err error ) bool {
233
232
preConditionFailedError := & scw.PreconditionFailedError {}
234
- return isHTTPCodeError (err , http .StatusPreconditionFailed ) || xerrors .As (err , & preConditionFailedError )
233
+ return isHTTPCodeError (err , http .StatusPreconditionFailed ) || errors .As (err , & preConditionFailedError )
235
234
}
236
235
237
236
// is403Error returns true if err is an HTTP 403 error
238
237
func is403Error (err error ) bool {
239
238
permissionsDeniedError := & scw.PermissionsDeniedError {}
240
- return isHTTPCodeError (err , http .StatusForbidden ) || xerrors .As (err , & permissionsDeniedError )
239
+ return isHTTPCodeError (err , http .StatusForbidden ) || errors .As (err , & permissionsDeniedError )
241
240
}
242
241
243
242
// is409Error return true is err is an HTTP 409 error
244
243
func is409Error (err error ) bool {
245
244
// check transient error
246
245
transientStateError := & scw.TransientStateError {}
247
- return isHTTPCodeError (err , http .StatusConflict ) || xerrors .As (err , & transientStateError )
246
+ return isHTTPCodeError (err , http .StatusConflict ) || errors .As (err , & transientStateError )
248
247
}
249
248
250
249
// organizationIDSchema returns a standard schema for a organization_id
@@ -558,7 +557,7 @@ func diffSuppressFuncIgnoreCase(k, oldValue, newValue string, d *schema.Resource
558
557
}
559
558
560
559
func diffSuppressFuncIgnoreCaseAndHyphen (k , oldValue , newValue string , d * schema.ResourceData ) bool {
561
- return strings .Replace (strings .ToLower (oldValue ), "-" , "_" , - 1 ) == strings .Replace (strings .ToLower (newValue ), "-" , "_" , - 1 )
560
+ return strings .ReplaceAll (strings .ToLower (oldValue ), "-" , "_" ) == strings .ReplaceAll (strings .ToLower (newValue ), "-" , "_" )
562
561
}
563
562
564
563
// diffSuppressFuncLocality is a SuppressDiffFunc to remove the locality from an ID when checking diff.
0 commit comments