-
Notifications
You must be signed in to change notification settings - Fork 224
/
list.go
42 lines (34 loc) · 839 Bytes
/
list.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package ips
import (
"context"
"github.com/spf13/cobra"
"github.com/superfly/flyctl/client"
"github.com/superfly/flyctl/internal/app"
"github.com/superfly/flyctl/internal/command"
"github.com/superfly/flyctl/internal/flag"
)
func newList() *cobra.Command {
const (
long = `Lists the IP addresses allocated to the application`
short = `List allocated IP addresses`
)
cmd := command.New("list", short, long, runIPAddressesList,
command.RequireSession,
command.RequireAppName,
)
flag.Add(cmd,
flag.App(),
flag.AppConfig(),
)
return cmd
}
func runIPAddressesList(ctx context.Context) error {
client := client.FromContext(ctx).API()
appName := app.NameFromContext(ctx)
ipAddresses, err := client.GetIPAddresses(ctx, appName)
if err != nil {
return err
}
renderListTable(ctx, ipAddresses)
return nil
}