Skip to content

Commit 76adcec

Browse files
committed
Refactor: Replace HTTP status code literal with constant
chore: remove verbose comment from import
1 parent 8eda21d commit 76adcec

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

pkg/cloudprovider/ibm/client.go

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"fmt"
2121
"os"
2222
"time"
23+
"net/http"
2324
)
2425

2526
// Client represents an IBM Cloud API client
@@ -127,23 +128,23 @@ func (c *Client) VPCInstanceExists(ctx context.Context, instanceID string) (bool
127128
return true, nil
128129
}
129130

130-
// containsNotFoundError checks if an error indicates a resource was not found
131131
func containsNotFoundError(err error) bool {
132-
if err == nil {
133-
return false
134-
}
135-
136-
errStr := err.Error()
137-
// Check for common "not found" error patterns from IBM Cloud VPC API
138-
return containsAnyString(errStr, []string{
139-
"not found",
140-
"404",
141-
"Not Found",
142-
"does not exist",
143-
"cannot be found",
144-
})
132+
if err == nil {
133+
return false
134+
}
135+
136+
errStr := err.Error()
137+
// Check for common "not found" error patterns from IBM Cloud VPC API
138+
return containsAnyString(errStr, []string{
139+
"not found",
140+
fmt.Sprintf("%d", http.StatusNotFound), // 404
141+
"Not Found",
142+
"does not exist",
143+
"cannot be found",
144+
})
145145
}
146146

147+
147148
// containsAnyString checks if a string contains any of the specified substrings
148149
func containsAnyString(s string, substrings []string) bool {
149150
for _, substring := range substrings {

0 commit comments

Comments
 (0)