Add support for setting stacks when creating session (#138)

* Add support for setting stacks when creating session

* Add exec endpoint and move dns stuff to another package

* Rename command and status code
This commit is contained in:
Marcos Nils
2017-05-11 10:34:16 -03:00
committed by GitHub
parent 24f8c9fc62
commit 62c5d3761d
9 changed files with 187 additions and 86 deletions

View File

@@ -274,3 +274,20 @@ func CreateInstance(session *Session, dindImage string) (*Instance, error) {
func DeleteContainer(id string) error {
return c.ContainerRemove(context.Background(), id, types.ContainerRemoveOptions{Force: true, RemoveVolumes: true})
}
func Exec(instanceName string, command []string) (int, error) {
e, err := c.ContainerExecCreate(context.Background(), instanceName, types.ExecConfig{Cmd: command})
if err != nil {
return 0, err
}
err = c.ContainerExecStart(context.Background(), e.ID, types.ExecStartCheck{})
if err != nil {
return 0, err
}
ins, err := c.ContainerExecInspect(context.Background(), e.ID)
if err != nil {
return 0, err
}
return ins.ExitCode, nil
}