Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 15 additions & 14 deletions pkg/cloudprovider/ibm/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"fmt"
"os"
"time"
"net/http"
)

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

// containsNotFoundError checks if an error indicates a resource was not found
func containsNotFoundError(err error) bool {
if err == nil {
return false
}

errStr := err.Error()
// Check for common "not found" error patterns from IBM Cloud VPC API
return containsAnyString(errStr, []string{
"not found",
"404",
"Not Found",
"does not exist",
"cannot be found",
})
if err == nil {
return false
}

errStr := err.Error()
// Check for common "not found" error patterns from IBM Cloud VPC API
return containsAnyString(errStr, []string{
"not found",
fmt.Sprintf("%d", http.StatusNotFound), // 404
"Not Found",
"does not exist",
"cannot be found",
})
}


// containsAnyString checks if a string contains any of the specified substrings
func containsAnyString(s string, substrings []string) bool {
for _, substring := range substrings {
Expand Down
Loading