1
0
Fork 0

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

@ -8,7 +8,6 @@ import (
"path/filepath"
"strings"
"github.com/Sirupsen/logrus"
"github.com/docker/cli/cli/command/image/build"
"github.com/docker/docker/api/types"
"github.com/docker/docker/builder/dockerignore"
@ -20,6 +19,7 @@ import (
"github.com/docker/docker/pkg/streamformatter"
"github.com/docker/docker/pkg/term"
"github.com/docker/libcompose/logger"
"github.com/sirupsen/logrus"
"golang.org/x/net/context"
)
@ -42,6 +42,7 @@ type DaemonBuilder struct {
ForceRemove bool
Pull bool
BuildArgs map[string]*string
CacheFrom []string
LoggerFactory logger.Factory
}
@ -96,6 +97,7 @@ func (d *DaemonBuilder) Build(ctx context.Context, imageName string) error {
Dockerfile: d.Dockerfile,
AuthConfigs: d.AuthConfigs,
BuildArgs: d.BuildArgs,
CacheFrom: d.CacheFrom,
})
if err != nil {
return err

View file

@ -11,12 +11,10 @@ import (
"golang.org/x/net/context"
"github.com/Sirupsen/logrus"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/network"
"github.com/docker/docker/client"
"github.com/docker/docker/pkg/promise"
"github.com/docker/docker/pkg/stdcopy"
"github.com/docker/docker/pkg/term"
"github.com/docker/go-connections/nat"
@ -24,6 +22,7 @@ import (
"github.com/docker/libcompose/labels"
"github.com/docker/libcompose/logger"
"github.com/docker/libcompose/project"
"github.com/sirupsen/logrus"
)
// Container holds information about a docker container and the service it is tied on.
@ -180,6 +179,7 @@ func (c *Container) Run(ctx context.Context, configOverride *config.ServiceConfi
errCh chan error
out, stderr io.Writer
in io.ReadCloser
inFd uintptr
)
if configOverride.StdinOpen {
@ -202,18 +202,22 @@ func (c *Container) Run(ctx context.Context, configOverride *config.ServiceConfi
return -1, err
}
// set raw terminal
inFd, _ := term.GetFdInfo(in)
state, err := term.SetRawTerminal(inFd)
if err != nil {
return -1, err
if configOverride.StdinOpen {
// set raw terminal
inFd, _ = term.GetFdInfo(in)
state, err := term.SetRawTerminal(inFd)
if err != nil {
return -1, err
}
// restore raw terminal
defer term.RestoreTerminal(inFd, state)
}
// restore raw terminal
defer term.RestoreTerminal(inFd, state)
// holdHijackedConnection (in goroutine)
errCh = promise.Go(func() error {
return holdHijackedConnection(configOverride.Tty, in, out, stderr, resp)
})
errCh = make(chan error, 1)
go func() {
errCh <- holdHijackedConnection(configOverride.Tty, in, out, stderr, resp)
}()
if err := c.client.ContainerStart(ctx, c.container.ID, types.ContainerStartOptions{}); err != nil {
return -1, err

View file

@ -32,7 +32,7 @@ func ListByFilter(ctx context.Context, clientInstance client.ContainerAPIClient,
func Get(ctx context.Context, clientInstance client.ContainerAPIClient, id string) (*types.ContainerJSON, error) {
container, err := clientInstance.ContainerInspect(ctx, id)
if err != nil {
if client.IsErrContainerNotFound(err) {
if client.IsErrNotFound(err) {
return nil, nil
}
return nil, err

View file

@ -7,7 +7,6 @@ import (
"io"
"os"
"github.com/Sirupsen/logrus"
"github.com/docker/distribution/reference"
"github.com/docker/docker/api/types"
"github.com/docker/docker/client"
@ -15,6 +14,7 @@ import (
"github.com/docker/docker/pkg/term"
"github.com/docker/docker/registry"
"github.com/docker/libcompose/docker/auth"
"github.com/sirupsen/logrus"
"golang.org/x/net/context"
)
@ -22,7 +22,7 @@ import (
func Exists(ctx context.Context, clt client.ImageAPIClient, image string) (bool, error) {
_, err := InspectImage(ctx, clt, image)
if err != nil {
if client.IsErrImageNotFound(err) {
if client.IsErrNotFound(err) {
return false, nil
}
return false, err

View file

@ -35,7 +35,9 @@ func (n *Network) fullName() string {
// Inspect inspect the current network
func (n *Network) Inspect(ctx context.Context) (types.NetworkResource, error) {
return n.client.NetworkInspect(ctx, n.fullName(), false)
return n.client.NetworkInspect(ctx, n.fullName(), types.NetworkInspectOptions{
Verbose: true,
})
}
// Remove removes the current network (from docker engine)
@ -53,13 +55,13 @@ func (n *Network) Remove(ctx context.Context) error {
func (n *Network) EnsureItExists(ctx context.Context) error {
networkResource, err := n.Inspect(ctx)
if n.external {
if client.IsErrNetworkNotFound(err) {
if client.IsErrNotFound(err) {
// FIXME(vdemeester) introduce some libcompose error type
return fmt.Errorf("Network %s declared as external, but could not be found. Please create the network manually using docker network create %s and try again", n.fullName(), n.fullName())
}
return err
}
if err != nil && client.IsErrNetworkNotFound(err) {
if err != nil && client.IsErrNotFound(err) {
return n.create(ctx)
}
if n.driver != "" && networkResource.Driver != n.driver {

View file

@ -3,7 +3,6 @@ package docker
import (
"golang.org/x/net/context"
"github.com/Sirupsen/logrus"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/filters"
"github.com/docker/libcompose/config"
@ -15,6 +14,7 @@ import (
"github.com/docker/libcompose/docker/volume"
"github.com/docker/libcompose/labels"
"github.com/docker/libcompose/project"
"github.com/sirupsen/logrus"
)
// NewProject creates a Project with the specified context.

View file

@ -4,10 +4,10 @@ import (
"fmt"
"strings"
"github.com/docker/cli/opts"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/network"
"github.com/docker/docker/api/types/strslice"
"github.com/docker/docker/runconfig/opts"
"github.com/docker/go-connections/nat"
"github.com/docker/go-units"
"github.com/docker/libcompose/config"

View file

@ -7,7 +7,6 @@ import (
"golang.org/x/net/context"
"github.com/Sirupsen/logrus"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/filters"
"github.com/docker/docker/api/types/network"
@ -26,6 +25,7 @@ import (
"github.com/docker/libcompose/project/options"
"github.com/docker/libcompose/utils"
"github.com/docker/libcompose/yaml"
"github.com/sirupsen/logrus"
)
// Service is a project.Service implementations.
@ -257,7 +257,7 @@ func (s *Service) Run(ctx context.Context, commandParts []string, options option
return -1, err
}
configOverride := &config.ServiceConfig{Command: commandParts, Tty: true, StdinOpen: true}
configOverride := &config.ServiceConfig{Command: commandParts, Tty: !options.DisableTty, StdinOpen: !options.DisableTty}
c, err := s.createContainer(ctx, namer, "", configOverride, true)
if err != nil {
@ -357,7 +357,7 @@ func (s *Service) connectContainerToNetworks(ctx context.Context, c *container.C
}
if s.serviceConfig.Networks != nil {
for _, network := range s.serviceConfig.Networks.Networks {
existingNetwork, ok := connectedNetworks[network.Name]
existingNetwork, ok := connectedNetworks[network.RealName]
if ok {
// FIXME(vdemeester) implement alias checking (to not disconnect/reconnect for nothing)
aliasPresent := false
@ -488,7 +488,7 @@ func (s *Service) OutOfSync(ctx context.Context, c *container.Container) (bool,
image, err := image.InspectImage(ctx, s.clientFactory.Create(s), c.ImageConfig())
if err != nil {
if client.IsErrImageNotFound(err) {
if client.IsErrNotFound(err) {
logrus.Debugf("Image %s do not exist, do not know if it's out of sync", c.Image())
return false, nil
}

View file

@ -7,7 +7,6 @@ import (
"golang.org/x/net/context"
"github.com/Sirupsen/logrus"
"github.com/docker/docker/api/types"
containertypes "github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/network"
@ -17,6 +16,7 @@ import (
"github.com/docker/libcompose/project"
"github.com/docker/libcompose/project/events"
util "github.com/docker/libcompose/utils"
"github.com/sirupsen/logrus"
)
func (s *Service) createContainer(ctx context.Context, namer Namer, oldContainer string, configOverride *config.ServiceConfig, oneOff bool) (*composecontainer.Container, error) {

View file

@ -51,13 +51,13 @@ func (v *Volume) Remove(ctx context.Context) error {
func (v *Volume) EnsureItExists(ctx context.Context) error {
volumeResource, err := v.Inspect(ctx)
if v.external {
if client.IsErrVolumeNotFound(err) {
if client.IsErrNotFound(err) {
// FIXME(shouze) introduce some libcompose error type
return fmt.Errorf("Volume %s declared as external, but could not be found. Please create the volume manually using docker volume create %s and try again", v.name, v.name)
}
return err
}
if err != nil && client.IsErrVolumeNotFound(err) {
if err != nil && client.IsErrNotFound(err) {
return v.create(ctx)
}
if volumeResource.Driver != v.driver {