-
Notifications
You must be signed in to change notification settings - Fork 224
/
list.go
48 lines (37 loc) · 947 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
43
44
45
46
47
48
package services
import (
"context"
"github.com/spf13/cobra"
"github.com/superfly/flyctl/client"
"github.com/superfly/flyctl/internal/appconfig"
"github.com/superfly/flyctl/internal/command"
"github.com/superfly/flyctl/internal/flag"
)
func newList() *cobra.Command {
const (
long = "List the services that are associated with an app"
short = "List services"
)
cmd := command.New("list", short, long, runList, command.RequireSession, command.RequireAppName)
cmd.Aliases = []string{"ls"}
flag.Add(cmd,
flag.App(),
flag.AppConfig(),
)
return cmd
}
func runList(ctx context.Context) error {
var (
client = client.FromContext(ctx).API()
appName = appconfig.NameFromContext(ctx)
)
appInfo, err := client.GetAppInfo(ctx, appName)
if err != nil {
return err
}
if appInfo.PlatformVersion == "machines" {
return ShowMachineServiceInfo(ctx, appInfo)
} else {
return showNomadServiceInfo(ctx, appInfo)
}
}