-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.go
65 lines (52 loc) · 1.68 KB
/
client.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
package docker
import (
"github.com/pkg/errors"
boxModel "github.com/hckops/hckctl/pkg/box/model"
"github.com/hckops/hckctl/pkg/client/docker"
commonDocker "github.com/hckops/hckctl/pkg/common/docker"
commonModel "github.com/hckops/hckctl/pkg/common/model"
"github.com/hckops/hckctl/pkg/event"
)
type DockerBoxClient struct {
client *docker.DockerClient
clientOpts *commonModel.DockerOptions
dockerCommon *commonDocker.DockerCommonClient
eventBus *event.EventBus
}
func NewDockerBoxClient(commonOpts *boxModel.CommonBoxOptions, dockerOpts *commonModel.DockerOptions) (*DockerBoxClient, error) {
return newDockerBoxClient(commonOpts, dockerOpts)
}
func (box *DockerBoxClient) Provider() boxModel.BoxProvider {
return boxModel.Docker
}
func (box *DockerBoxClient) Events() *event.EventBus {
return box.eventBus
}
func (box *DockerBoxClient) Create(opts *boxModel.CreateOptions) (*boxModel.BoxInfo, error) {
defer box.close()
return box.createBox(opts)
}
func (box *DockerBoxClient) Connect(opts *boxModel.ConnectOptions) error {
defer box.close()
return box.connectBox(opts)
}
func (box *DockerBoxClient) Describe(name string) (*boxModel.BoxDetails, error) {
defer box.close()
return box.describeBox(name)
}
func (box *DockerBoxClient) List() ([]boxModel.BoxInfo, error) {
defer box.close()
return box.listBoxes()
}
func (box *DockerBoxClient) Delete(names []string) ([]string, error) {
defer box.close()
return box.deleteBoxes(names)
}
func (box *DockerBoxClient) Clean() error {
defer box.close()
// TODO remove network and volumes
return errors.New("not implemented")
}
func (box *DockerBoxClient) Version() (string, error) {
return "", errors.New("not implemented")
}