-
Notifications
You must be signed in to change notification settings - Fork 221
/
platform.go
58 lines (43 loc) · 1.47 KB
/
platform.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
49
50
51
52
53
54
55
56
57
58
package cmd
import (
"fmt"
"github.com/skratchdot/open-golang/open"
"github.com/superfly/flyctl/cmdctx"
"github.com/superfly/flyctl/internal/client"
"github.com/superfly/flyctl/docstrings"
"github.com/superfly/flyctl/cmd/presenters"
)
func newPlatformCommand(client *client.Client) *Command {
platformStrings := docstrings.Get("platform")
cmd := BuildCommandKS(nil, nil, platformStrings, client, requireAppName)
regionsStrings := docstrings.Get("platform.regions")
BuildCommandKS(cmd, runPlatformRegions, regionsStrings, client, requireSession)
vmSizesStrings := docstrings.Get("platform.vmsizes")
BuildCommandKS(cmd, runPlatformVMSizes, vmSizesStrings, client, requireSession)
statusStrings := docstrings.Get("platform.status")
BuildCommandKS(cmd, runPlatformStatus, statusStrings, client, requireSession, requireAppName)
return cmd
}
func runPlatformRegions(ctx *cmdctx.CmdContext) error {
regions, _, err := ctx.Client.API().PlatformRegions()
if err != nil {
return err
}
return ctx.Frender(cmdctx.PresenterOption{
Presentable: &presenters.Regions{Regions: regions},
})
}
func runPlatformVMSizes(ctx *cmdctx.CmdContext) error {
sizes, err := ctx.Client.API().PlatformVMSizes()
if err != nil {
return err
}
return ctx.Frender(cmdctx.PresenterOption{
Presentable: &presenters.VMSizes{VMSizes: sizes},
})
}
func runPlatformStatus(ctx *cmdctx.CmdContext) error {
docsURL := "https://status.fly.io/"
fmt.Println("Opening", docsURL)
return open.Run(docsURL)
}