@@ -27,6 +27,7 @@ import (
27
27
"github.com/Azure/azure-service-operator/v2/internal/controllers"
28
28
"github.com/Azure/azure-service-operator/v2/internal/genericarmclient"
29
29
"github.com/Azure/azure-service-operator/v2/internal/reflecthelpers"
30
+ "github.com/Azure/azure-service-operator/v2/internal/set"
30
31
"github.com/Azure/azure-service-operator/v2/pkg/genruntime"
31
32
"github.com/Azure/azure-service-operator/v2/pkg/genruntime/extensions"
32
33
)
@@ -357,6 +358,16 @@ func (i *importableARMResource) importChildResources(
357
358
return subResources , nil
358
359
}
359
360
361
+ // skipCodes is a set of error codes that we can safely skip when importing resources.
362
+ // These error codes represent cases where the request we've made doesn't make sense,
363
+ // so there's no point in alerting the user to the details.
364
+ var skipCodes = set .Make (
365
+ "RequestUrlInvalid" ,
366
+ "ValidationFailed" ,
367
+ "NoRegisteredProviderFound" ,
368
+ "ResourceTypeNotSupported" ,
369
+ )
370
+
360
371
func (* importableARMResource ) classifyError (err error ) (string , bool ) {
361
372
var responseError * azcore.ResponseError
362
373
if errors .As (err , & responseError ) {
@@ -371,10 +382,8 @@ func (*importableARMResource) classifyError(err error) (string, bool) {
371
382
}
372
383
373
384
if responseError .StatusCode == http .StatusBadRequest {
374
- if strings .Contains (responseError .Error (), "RequestUrlInvalid" ) ||
375
- strings .Contains (responseError .Error (), "ValidationFailed" ) ||
376
- strings .Contains (responseError .Error (), "NoRegisteredProviderFound" ) {
377
- // We constructed an invalid URL
385
+ if skipCodes .Contains (responseError .ErrorCode ) {
386
+ // We made a request for something that doesn't exist, or is otherwise invalid
378
387
// (Seems that some extension resources aren't permitted on some resource types)
379
388
// An empty error is special cased as a silent skip, so we don't alarm casual users
380
389
return "" , true
0 commit comments