Reimplement terminal connections

This commit is contained in:
Jonathan Leibiusky @xetorthio
2017-09-07 15:27:25 -03:00
parent f3307d964c
commit 150b089602
6 changed files with 309 additions and 154 deletions

View File

@@ -51,6 +51,8 @@ type DockerApi interface {
Exec(instanceName string, command []string) (int, error)
SwarmInit() (*SwarmTokens, error)
SwarmJoin(addr, token string) error
ConfigCreate(name string, labels map[string]string, data []byte) error
ConfigDelete(name string) error
}
type SwarmTokens struct {
@@ -62,6 +64,18 @@ type docker struct {
c *client.Client
}
func (d *docker) ConfigCreate(name string, labels map[string]string, data []byte) error {
config := swarm.ConfigSpec{}
config.Name = name
config.Labels = labels
config.Data = data
_, err := d.c.ConfigCreate(context.Background(), config)
return err
}
func (d *docker) ConfigDelete(name string) error {
return d.c.ConfigRemove(context.Background(), name)
}
func (d *docker) CreateNetwork(id string, opts types.NetworkCreate) error {
_, err := d.c.NetworkCreate(context.Background(), id, opts)

View File

@@ -104,6 +104,14 @@ func (m *Mock) SwarmJoin(addr, token string) error {
args := m.Called(addr, token)
return args.Error(0)
}
func (m *Mock) ConfigCreate(name string, labels map[string]string, data []byte) error {
args := m.Called(name, labels, data)
return args.Error(0)
}
func (m *Mock) ConfigDelete(name string) error {
args := m.Called(name)
return args.Error(0)
}
type MockConn struct {
}