Migrate Sirupsen to sirupsen.

This commit is contained in:
Ludovic Fernandez 2018-01-22 12:16:03 +01:00 committed by Traefiker
parent c134dcd6fe
commit fb4ba7af2b
684 changed files with 92394 additions and 33943 deletions

View file

@ -7,6 +7,8 @@ package docker
import (
"fmt"
"github.com/docker/docker/api/types"
"github.com/docker/docker/client"
)
@ -53,12 +55,13 @@ type APIClient interface {
// NewProjectFromEnv creates a project with a client that is build from environment variables.
func NewProjectFromEnv() (*Project, error) {
client, err := client.NewEnvClient()
cli, err := client.NewEnvClient()
if err != nil {
return nil, err
}
client.UpdateClientVersion(CurrentAPIVersion)
return NewProject(client), nil
ping := types.Ping{APIVersion: CurrentAPIVersion}
cli.NegotiateAPIVersionPing(ping)
return NewProject(cli), nil
}
// NewProject creates a project with the given client and the default attributes.

View file

@ -19,7 +19,7 @@ func (p *Project) ensureImageExists(ref string, force bool) error {
if !force {
// Check if ref is already there
_, _, err := p.Client.ImageInspectWithRaw(context.Background(), ref)
if err != nil && !client.IsErrImageNotFound(err) {
if err != nil && !client.IsErrNotFound(err) {
return err
}
if err == nil {

View file

@ -8,10 +8,7 @@ import (
// Remove removes the container
func (p *Project) Remove(containerID string) error {
if err := p.Client.ContainerRemove(context.Background(), containerID, types.ContainerRemoveOptions{
return p.Client.ContainerRemove(context.Background(), containerID, types.ContainerRemoveOptions{
Force: true,
}); err != nil {
return err
}
return nil
})
}

View file

@ -14,9 +14,6 @@ func (p *Project) Stop(containerID string) error {
// StopWithTimeout stops the container with the specified timeout.
func (p *Project) StopWithTimeout(containerID string, timeout int) error {
timeoutDuration := time.Duration(timeout) * time.Second
if err := p.Client.ContainerStop(context.Background(), containerID, &timeoutDuration); err != nil {
return err
}
return nil
return p.Client.ContainerStop(context.Background(), containerID, &timeoutDuration)
}