-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathclient.go
More file actions
116 lines (97 loc) · 3.02 KB
/
client.go
File metadata and controls
116 lines (97 loc) · 3.02 KB
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
package client
import (
"errors"
"github.com/deis/deis/deisctl/backend"
"github.com/deis/deis/deisctl/backend/fleet"
"github.com/deis/deis/deisctl/cmd"
)
// DeisCtlClient manages Deis components, configuration, and related tasks.
type DeisCtlClient interface {
Config() error
Install(targets []string) error
Journal(targets []string) error
List() error
RefreshUnits() error
Restart(targets []string) error
Scale(targets []string) error
Start(targets []string) error
Status(targets []string) error
Stop(targets []string) error
Uninstall(targets []string) error
Update() error
}
// Client uses a backend to implement the DeisCtlClient interface.
type Client struct {
Backend backend.Backend
}
// NewClient returns a Client using the requested backend.
// The only backend currently supported is "fleet".
func NewClient(requestedBackend string) (*Client, error) {
var backend backend.Backend
if requestedBackend == "" {
requestedBackend = "fleet"
}
switch requestedBackend {
case "fleet":
b, err := fleet.NewClient()
if err != nil {
return nil, err
}
backend = b
default:
return nil, errors.New("invalid backend")
}
return &Client{Backend: backend}, nil
}
// Config gets or sets a configuration value from the cluster.
//
// A configuration value is stored and retrieved from a key/value store (in this case, etcd)
// at /deis/<component>/<config>. Configuration values are typically used for component-level
// configuration, such as enabling TLS for the routers.
func (c *Client) Config() error {
return cmd.Config()
}
// Install loads components' definitions from local unit files.
func (c *Client) Install(targets []string) error {
return cmd.Install(c.Backend, targets)
}
// Journal prints log output for the specified components.
func (c *Client) Journal(targets []string) error {
return cmd.Journal(c.Backend, targets)
}
// List prints a summary of installed components.
func (c *Client) List() error {
return cmd.ListUnits(c.Backend)
}
// RefreshUnits overwrites local unit files with those requested.
func (c *Client) RefreshUnits() error {
return cmd.RefreshUnits()
}
// Restart stops and then starts components.
func (c *Client) Restart(targets []string) error {
return cmd.Restart(c.Backend, targets)
}
// Scale grows or shrinks the number of running components.
func (c *Client) Scale(targets []string) error {
return cmd.Scale(c.Backend, targets)
}
// Start activates the specified components.
func (c *Client) Start(targets []string) error {
return cmd.Start(c.Backend, targets)
}
// Status prints the current state of components.
func (c *Client) Status(targets []string) error {
return cmd.Status(c.Backend, targets)
}
// Stop deactivates the specified components.
func (c *Client) Stop(targets []string) error {
return cmd.Stop(c.Backend, targets)
}
// Uninstall unloads components' definitions.
func (c *Client) Uninstall(targets []string) error {
return cmd.Uninstall(c.Backend, targets)
}
// Update changes the platform version on a cluster host.
func (c *Client) Update() error {
return cmd.Update()
}