Skip to content

Commit ef3fd1c

Browse files
committed
fixes.
1 parent bc08699 commit ef3fd1c

File tree

3 files changed

+4
-23
lines changed

3 files changed

+4
-23
lines changed

cmd/compute/blockstorage/blockstorage_list.go

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
exocmd "github.com/exoscale/cli/cmd"
1111
"github.com/exoscale/cli/pkg/globalstate"
1212
"github.com/exoscale/cli/pkg/output"
13+
"github.com/exoscale/cli/utils"
1314
v3 "github.com/exoscale/egoscale/v3"
1415
)
1516

@@ -54,20 +55,10 @@ func (c *blockStorageListCmd) CmdRun(_ *cobra.Command, _ []string) error {
5455
client := globalstate.EgoscaleV3Client
5556
ctx := exocmd.GContext
5657

57-
resp, err := client.ListZones(ctx)
58+
zones, err := utils.AllZonesV3(ctx, client, c.Zone)
5859
if err != nil {
5960
return err
6061
}
61-
zones := resp.Zones
62-
63-
if c.Zone != "" {
64-
endpoint, err := client.GetZoneAPIEndpoint(ctx, c.Zone)
65-
if err != nil {
66-
return err
67-
}
68-
69-
zones = []v3.Zone{{APIEndpoint: endpoint}}
70-
}
7162

7263
output := make(blockStorageListOutput, 0)
7364
for _, zone := range zones {

cmd/compute/private_network/private_network_list.go

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,19 +53,10 @@ func (c *privateNetworkListCmd) CmdRun(_ *cobra.Command, _ []string) error {
5353
client := globalstate.EgoscaleV3Client
5454
ctx := exocmd.GContext
5555

56-
resp, err := client.ListZones(ctx)
56+
zones, err := utils.AllZonesV3(ctx, client, c.Zone)
5757
if err != nil {
5858
return err
5959
}
60-
zones := resp.Zones
61-
62-
if c.Zone != "" {
63-
endpoint, err := client.GetZoneAPIEndpoint(ctx, c.Zone)
64-
if err != nil {
65-
return err
66-
}
67-
zones = []v3.Zone{{APIEndpoint: endpoint}}
68-
}
6960

7061
out := make(privateNetworkListOutput, 0)
7162
res := make(chan privateNetworkListItemOutput)

utils/utils.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func AllZonesV3(ctx context.Context, client *v3.Client, zoneName v3.ZoneName) ([
4343
if err != nil {
4444
return nil, fmt.Errorf("get zone api endpoint: find zone: %w", err)
4545
}
46-
zones = []v3.Zone{{APIEndpoint: zone.APIEndpoint}}
46+
zones = []v3.Zone{zone}
4747
}
4848

4949
return zones, nil
@@ -228,7 +228,6 @@ func ForEveryZone(zones []v3.Zone, f func(zone v3.Zone) error) error {
228228
meg := new(multierror.Group)
229229

230230
for _, zone := range zones {
231-
zone := zone
232231
meg.Go(func() error {
233232
return f(zone)
234233
})

0 commit comments

Comments
 (0)