-
Notifications
You must be signed in to change notification settings - Fork 221
/
machine.go
57 lines (44 loc) · 983 Bytes
/
machine.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
package machine
import (
"context"
"github.com/spf13/cobra"
"github.com/superfly/flyctl/api"
"github.com/superfly/flyctl/client"
"github.com/superfly/flyctl/internal/command"
)
func New() *cobra.Command {
const (
short = "Commands that manage machines"
long = short + "\n"
usage = "machine <command>"
)
cmd := command.New(usage, short, long, nil)
cmd.Args = cobra.NoArgs
cmd.Aliases = []string{"machines", "m"}
cmd.AddCommand(
newKill(),
newList(),
newRemove(),
newRun(),
newStart(),
newStop(),
newStatus(),
newProxy(),
newLaunch(),
newClone(),
)
return cmd
}
func appFromMachineOrName(ctx context.Context, machineId string, appName string) (app *api.AppCompact, err error) {
client := client.FromContext(ctx).API()
if appName == "" {
machine, err := client.GetMachine(ctx, machineId)
if err != nil {
return nil, err
}
app = machine.App
} else {
app, err = client.GetAppCompact(ctx, appName)
}
return app, err
}