Skip to content

Commit 767576c

Browse files
Utilize linodego.IsNotFound function to check whether the error is not found error (#2025)
1 parent 8b7bc88 commit 767576c

File tree

25 files changed

+31
-31
lines changed

25 files changed

+31
-31
lines changed

linode/databaseaccesscontrols/resource.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func readResource(ctx context.Context, d *schema.ResourceData, meta interface{})
3636

3737
allowList, err := getDBAllowListByEngine(ctx, client, dbType, dbID)
3838
if err != nil {
39-
if lerr, ok := err.(*linodego.Error); ok && lerr.Code == 404 {
39+
if linodego.IsNotFound(err) {
4040
log.Printf("[WARN] allow_list %q from state because it no longer exists", d.Id())
4141
d.SetId("")
4242
return nil

linode/databasemysql/resource.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func readResource(ctx context.Context, d *schema.ResourceData, meta interface{})
5050

5151
db, err := client.GetMySQLDatabase(ctx, id)
5252
if err != nil {
53-
if lerr, ok := err.(*linodego.Error); ok && lerr.Code == 404 {
53+
if linodego.IsNotFound(err) {
5454
log.Printf("[WARN] removing MySQL database ID %q from state because it no longer exists", d.Id())
5555
d.SetId("")
5656
return nil

linode/databasemysqlv2/framework_resource.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ func (r *Resource) Read(
227227

228228
db, err := client.GetMySQLDatabase(ctx, id)
229229
if err != nil {
230-
if lerr, ok := err.(*linodego.Error); ok && lerr.Code == 404 {
230+
if linodego.IsNotFound(err) {
231231
resp.Diagnostics.AddWarning(
232232
"Database no longer exists",
233233
fmt.Sprintf(

linode/databasepostgresql/resource.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func readResource(ctx context.Context, d *schema.ResourceData, meta interface{})
5050

5151
db, err := client.GetPostgresDatabase(ctx, id)
5252
if err != nil {
53-
if lerr, ok := err.(*linodego.Error); ok && lerr.Code == 404 {
53+
if linodego.IsNotFound(err) {
5454
log.Printf("[WARN] removing PostgreSQL database ID %q from state because it no longer exists", d.Id())
5555
d.SetId("")
5656
return nil

linode/databasepostgresqlv2/framework_resource.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ func (r *Resource) Read(
226226

227227
db, err := client.GetPostgresDatabase(ctx, id)
228228
if err != nil {
229-
if lerr, ok := err.(*linodego.Error); ok && lerr.Code == 404 {
229+
if linodego.IsNotFound(err) {
230230
resp.Diagnostics.AddWarning(
231231
"Database no longer exists",
232232
fmt.Sprintf(

linode/domain/resource.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func readResource(ctx context.Context, d *schema.ResourceData, meta interface{})
4444

4545
domain, err := client.GetDomain(ctx, id)
4646
if err != nil {
47-
if lerr, ok := err.(*linodego.Error); ok && lerr.Code == 404 {
47+
if linodego.IsNotFound(err) {
4848
log.Printf("[WARN] removing Linode Domain ID %q from state because it no longer exists", d.Id())
4949
d.SetId("")
5050
return nil

linode/domainrecord/resource.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ func readResource(ctx context.Context, d *schema.ResourceData, meta interface{})
7474

7575
record, err := client.GetDomainRecord(ctx, domainID, id)
7676
if err != nil {
77-
if lerr, ok := err.(*linodego.Error); ok && lerr.Code == 404 {
77+
if linodego.IsNotFound(err) {
7878
log.Printf("[WARN] removing Linode Domain Record ID %q from state because it no longer exists", d.Id())
7979
d.SetId("")
8080
return nil

linode/firewalldevice/framework_resource.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ func (r *Resource) Read(
122122

123123
device, err := client.GetFirewallDevice(ctx, firewallID, id)
124124
if err != nil {
125-
if lerr, ok := err.(*linodego.Error); ok && lerr.Code == 404 {
125+
if linodego.IsNotFound(err) {
126126
resp.Diagnostics.AddWarning(
127127
"Firewall Device No Longer Exists",
128128
fmt.Sprintf(
@@ -213,7 +213,7 @@ func (r *Resource) Delete(
213213

214214
err := client.DeleteFirewallDevice(ctx, firewallID, id)
215215
if err != nil {
216-
if lerr, ok := err.(*linodego.Error); ok && lerr.Code == 404 {
216+
if linodego.IsNotFound(err) {
217217
resp.Diagnostics.AddWarning(
218218
fmt.Sprintf(
219219
"Attempted to Delete Firewall Device %d But Resource Not Found",

linode/instancedisk/framework_resource.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ func (r *Resource) Read(
189189

190190
disk, err := client.GetInstanceDisk(ctx, linodeID, id)
191191
if err != nil {
192-
if lerr, ok := err.(*linodego.Error); ok && lerr.Code == 404 {
192+
if linodego.IsNotFound(err) {
193193
resp.Diagnostics.AddWarning(
194194
"Disk Not Found",
195195
fmt.Sprintf(

linode/instanceip/framework_resource.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ func (r *Resource) Read(
155155
}
156156
ip, err := client.GetInstanceIPAddress(ctx, linodeID, address)
157157
if err != nil {
158-
if lerr, ok := err.(*linodego.Error); ok && lerr.Code == 404 {
158+
if linodego.IsNotFound(err) {
159159
resp.Diagnostics.AddWarning(
160160
"Instance IP No Longer Exists",
161161
fmt.Sprintf(

0 commit comments

Comments
 (0)