forked from crisidev/fleet-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fleet_client_cli.go
81 lines (61 loc) · 1.52 KB
/
fleet_client_cli.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package main
import (
"github.com/juju/errgo"
"os/exec"
)
const (
FLEETCTL = "fleetctl"
ENDPOINT_OPTION = "--endpoint"
ENDPOINT_VALUE = "http://172.17.42.1:4001"
)
type ClientCLI struct {
etcdPeer string
}
func NewClientCLI() FleetClient {
return NewClientCLIWithPeer(ENDPOINT_VALUE)
}
func NewClientCLIWithPeer(etcdPeer string) FleetClient {
return &ClientCLI{
etcdPeer: etcdPeer,
}
}
func (this *ClientCLI) Submit(name, filePath string) error {
cmd := exec.Command(FLEETCTL, ENDPOINT_OPTION, this.etcdPeer, "submit", filePath)
_, err := execCmd(cmd)
if err != nil {
return errgo.Mask(err)
}
return nil
}
func (this *ClientCLI) Start(name string) error {
cmd := exec.Command(FLEETCTL, ENDPOINT_OPTION, this.etcdPeer, "start", "--no-block=true", name)
_, err := execCmd(cmd)
if err != nil {
return errgo.Mask(err)
}
return nil
}
func (this *ClientCLI) Stop(name string) error {
cmd := exec.Command(FLEETCTL, ENDPOINT_OPTION, this.etcdPeer, "stop", "--no-block=true", name)
_, err := execCmd(cmd)
if err != nil {
return errgo.Mask(err)
}
return nil
}
func (this *ClientCLI) Load(name string) error {
cmd := exec.Command(FLEETCTL, ENDPOINT_OPTION, this.etcdPeer, "load", "--no-block=true", name)
_, err := execCmd(cmd)
if err != nil {
return errgo.Mask(err)
}
return nil
}
func (this *ClientCLI) Destroy(name string) error {
cmd := exec.Command(FLEETCTL, ENDPOINT_OPTION, this.etcdPeer, "destroy", name)
_, err := execCmd(cmd)
if err != nil {
return errgo.Mask(err)
}
return nil
}