-
Notifications
You must be signed in to change notification settings - Fork 112
Expand file tree
/
Copy pathclient.go
More file actions
112 lines (94 loc) · 3.07 KB
/
client.go
File metadata and controls
112 lines (94 loc) · 3.07 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
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(argv []string) error
Install(argv []string) error
Journal(argv []string) error
List(argv []string) error
RefreshUnits(argv []string) error
Restart(argv []string) error
Scale(argv []string) error
Start(argv []string) error
Status(argv []string) error
Stop(argv []string) error
Uninstall(argv []string) 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(argv []string) error {
return cmd.Config(argv)
}
// Install loads the definitions of components from local unit files.
// After Install, the components will be available to Start.
func (c *Client) Install(argv []string) error {
return cmd.Install(argv, c.Backend)
}
// Journal prints log output for the specified components.
func (c *Client) Journal(argv []string) error {
return cmd.Journal(argv, c.Backend)
}
// List prints a summary of installed components.
func (c *Client) List(argv []string) error {
return cmd.ListUnits(argv, c.Backend)
}
// RefreshUnits overwrites local unit files with those requested.
func (c *Client) RefreshUnits(argv []string) error {
return cmd.RefreshUnits(argv)
}
// Restart stops and then starts components.
func (c *Client) Restart(argv []string) error {
return cmd.Restart(argv, c.Backend)
}
// Scale grows or shrinks the number of running components.
func (c *Client) Scale(argv []string) error {
return cmd.Scale(argv, c.Backend)
}
// Start activates the specified components.
func (c *Client) Start(argv []string) error {
return cmd.Start(argv, c.Backend)
}
// Status prints the current status of components.
func (c *Client) Status(argv []string) error {
return cmd.Status(argv, c.Backend)
}
// Stop deactivates the specified components.
func (c *Client) Stop(argv []string) error {
return cmd.Stop(argv, c.Backend)
}
// Uninstall unloads the definitions of the specified components.
// After Uninstall, the components will be unavailable until Install is called.
func (c *Client) Uninstall(argv []string) error {
return cmd.Uninstall(argv, c.Backend)
}