Skip to content

Commit

Permalink
Removed usage of direct tags API for retrieving tags using resource C…
Browse files Browse the repository at this point in the history
…RN (#4209)

* Removed usage of direct tags API for retrieving tags using resource CRN

Removed usage of direct tags API for retrieving tags using resource CRN

* fix: fixed syntax error
  • Loading branch information
vbontempi authored Dec 7, 2022
1 parent e4be24c commit 01964bc
Showing 1 changed file with 3 additions and 15 deletions.
18 changes: 3 additions & 15 deletions ibm/service/globaltagging/resource_ibm_resource_tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"

"github.com/IBM-Cloud/bluemix-go/bmxerror"
"github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns"
"github.com/IBM-Cloud/terraform-provider-ibm/ibm/flex"
"github.com/IBM-Cloud/terraform-provider-ibm/ibm/validate"
Expand Down Expand Up @@ -208,21 +207,10 @@ func resourceIBMResourceTagRead(d *schema.ResourceData, meta interface{}) error
d.Set(acccountID, acctID)
}
}
tagList, err := flex.GetGlobalTagsUsingCRN(meta, rID, rType, tType)
if err != nil {
if apierr, ok := err.(bmxerror.RequestFailure); ok && apierr.StatusCode() == 404 {
d.SetId("")
return nil
} else if strings.Contains(err.Error(), "Too Many Requests") {

tagList, err = flex.GetGlobalTagsUsingSearchAPI(meta, rID, rType, tType)
if err != nil {
return fmt.Errorf("[ERROR] Error getting resource tags for: %s with error : %s", rID, err)
}
} else {
return fmt.Errorf("[ERROR] Error getting resource tags for: %s with error : %s", rID, err)
}

tagList, err := flex.GetGlobalTagsUsingSearchAPI(meta, rID, rType, tType)
if err != nil {
return fmt.Errorf("[ERROR] Error getting resource tags for: %s with error : %s", rID, err)
}

d.Set(resourceID, rID)
Expand Down

0 comments on commit 01964bc

Please sign in to comment.