Skip to content

Commit

Permalink
Much better error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
majst01 committed Sep 2, 2024
1 parent bd4efa1 commit 8a55dc6
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions pkg/resources/metal/ip.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,14 @@ func (ms *MetalService) FindProjectIP(ctx context.Context, projectID, ip string)
return nil, err
}

if len(resp.Payload) != 1 {
switch len(resp.Payload) {
case 0:
return nil, fmt.Errorf("ip %s for projectID: %s not allocated", ip, projectID)
case 1:
return resp.Payload[0], nil
default:
return nil, fmt.Errorf("ip %s is ambiguous for projectID: %s", ip, projectID)
}

return resp.Payload[0], nil
}

// FindProjectIPsWithTag returns the IPs of the given project that also have the given tag.
Expand Down

0 comments on commit 8a55dc6

Please sign in to comment.