Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

security-group show: fix empty response if an API endpoint is misbehaving #660

Merged
Merged
Changes from 1 commit
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
15 changes: 11 additions & 4 deletions utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"crypto/rand"
"encoding/base64"
"errors"
"fmt"
"net"
"strconv"
Expand Down Expand Up @@ -49,15 +50,21 @@ func GetInstancesInSecurityGroup(ctx context.Context, client *v2.Client, securit

instances, err := client.ListInstances(ctx, zone)
if err != nil {
return err
if !errors.Is(err, exoapi.ErrNotFound) {
return err
}
} else {
allInstances = append(allInstances, instances...)
}

allInstances = append(allInstances, instances...)

return nil
})
if err != nil {
return nil, err
if allInstances == nil {
return nil, err
} else {
fmt.Printf("error while listing instances in security group: %s", err)
}
}

var instancesInSG []*v2.Instance
Expand Down
Loading