From 258dd8bc3d052d78ee7a87dd8ec1d577250b6893 Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Thu, 13 Aug 2015 14:32:56 -0700 Subject: [PATCH] Update godeps libcompose and docker-from-scratch --- Godeps/Godeps.json | 22 ++- .../docker/libcompose/docker/container.go | 20 +- .../docker/libcompose/docker/convert_test.go | 2 +- .../docker/libcompose/docker/project.go | 6 +- .../docker/libcompose/project/project.go | 15 +- .../docker/libcompose/project/project_test.go | 21 ++ .../libcompose/project/service-wrapper.go | 6 +- .../docker/libcompose/project/types.go | 180 ++++++++++++++---- .../docker-from-scratch/scripts/download | 2 +- .../docker-from-scratch/scripts/version | 2 +- 10 files changed, 205 insertions(+), 71 deletions(-) create mode 100644 Godeps/_workspace/src/github.com/docker/libcompose/project/project_test.go diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 840f7479..17d14f1f 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -250,27 +250,33 @@ }, { "ImportPath": "github.com/docker/libcompose/cli/logger", - "Rev": "7dc5362063183024d12cafaa2ba8ea8830b7ab62" + "Comment": "v0.0.2-ros", + "Rev": "48a1ac9a0aceeea67279b689e446a8dfcdc7033f" }, { "ImportPath": "github.com/docker/libcompose/docker", - "Rev": "7dc5362063183024d12cafaa2ba8ea8830b7ab62" + "Comment": "v0.0.2-ros", + "Rev": "48a1ac9a0aceeea67279b689e446a8dfcdc7033f" }, { "ImportPath": "github.com/docker/libcompose/logger", - "Rev": "7dc5362063183024d12cafaa2ba8ea8830b7ab62" + "Comment": "v0.0.2-ros", + "Rev": "48a1ac9a0aceeea67279b689e446a8dfcdc7033f" }, { "ImportPath": "github.com/docker/libcompose/lookup", - "Rev": "7dc5362063183024d12cafaa2ba8ea8830b7ab62" + "Comment": "v0.0.2-ros", + "Rev": "48a1ac9a0aceeea67279b689e446a8dfcdc7033f" }, { "ImportPath": "github.com/docker/libcompose/project", - "Rev": "7dc5362063183024d12cafaa2ba8ea8830b7ab62" + "Comment": "v0.0.2-ros", + "Rev": "48a1ac9a0aceeea67279b689e446a8dfcdc7033f" }, { "ImportPath": "github.com/docker/libcompose/utils", - "Rev": "7dc5362063183024d12cafaa2ba8ea8830b7ab62" + "Comment": "v0.0.2-ros", + "Rev": "48a1ac9a0aceeea67279b689e446a8dfcdc7033f" }, { "ImportPath": "github.com/docker/libcontainer/netlink", @@ -331,8 +337,8 @@ }, { "ImportPath": "github.com/rancher/docker-from-scratch", - "Comment": "1.8.0-rc3", - "Rev": "61019634b705c0d3ac2aa115baf9568bf55393c2" + "Comment": "1.8.1", + "Rev": "f348f946923bd2938a56f3bee21cf44431e05181" }, { "ImportPath": "github.com/rancher/netconf", diff --git a/Godeps/_workspace/src/github.com/docker/libcompose/docker/container.go b/Godeps/_workspace/src/github.com/docker/libcompose/docker/container.go index 1eeabb06..3e03b1f8 100644 --- a/Godeps/_workspace/src/github.com/docker/libcompose/docker/container.go +++ b/Godeps/_workspace/src/github.com/docker/libcompose/docker/container.go @@ -199,9 +199,15 @@ func (c *Container) Up(imageName string) error { } if !info.State.Running { - logrus.Debugf("Starting container: %s: %#v", container.Id) - err := c.client.StartContainer(container.Id, nil) - return err + logrus.Debugf("Starting container: %s: %#v", container.Id, info.HostConfig) + err = c.populateAdditionalHostConfig(info.HostConfig) + if err != nil { + return err + } + + if err := c.client.StartContainer(container.Id, nil); err != nil { + return err + } c.service.context.Project.Notify(project.CONTAINER_STARTED, c.service.Name(), map[string]string{ "name": c.Name(), @@ -267,7 +273,13 @@ func (c *Container) createContainer(imageName, oldContainer string) (*dockerclie id, err := c.client.CreateContainer(config, c.name) if err != nil && err.Error() == "Not found" { - err = c.pull(config.Image) + logrus.Debugf("Not Found, pulling image %s", config.Image) + if err = c.pull(config.Image); err != nil { + return nil, err + } + if id, err = c.client.CreateContainer(config, c.name); err != nil { + return nil, err + } } if err != nil { diff --git a/Godeps/_workspace/src/github.com/docker/libcompose/docker/convert_test.go b/Godeps/_workspace/src/github.com/docker/libcompose/docker/convert_test.go index cbdcfa35..bb81162a 100644 --- a/Godeps/_workspace/src/github.com/docker/libcompose/docker/convert_test.go +++ b/Godeps/_workspace/src/github.com/docker/libcompose/docker/convert_test.go @@ -1,8 +1,8 @@ package docker import ( - shlex "github.com/flynn/go-shlex" "github.com/docker/libcompose/project" + shlex "github.com/flynn/go-shlex" "github.com/stretchr/testify/assert" "testing" ) diff --git a/Godeps/_workspace/src/github.com/docker/libcompose/docker/project.go b/Godeps/_workspace/src/github.com/docker/libcompose/docker/project.go index d272e02b..01c3af07 100644 --- a/Godeps/_workspace/src/github.com/docker/libcompose/docker/project.go +++ b/Godeps/_workspace/src/github.com/docker/libcompose/docker/project.go @@ -27,11 +27,11 @@ func NewProject(context *Context) (*project.Project, error) { } if context.ClientFactory == nil { - if factory, err := NewDefaultClientFactory(ClientOpts{}); err != nil { + factory, err := NewDefaultClientFactory(ClientOpts{}) + if err != nil { return nil, err - } else { - context.ClientFactory = factory } + context.ClientFactory = factory } p := project.NewProject(&context.Context) diff --git a/Godeps/_workspace/src/github.com/docker/libcompose/project/project.go b/Godeps/_workspace/src/github.com/docker/libcompose/project/project.go index 91f0d384..d01cefd6 100644 --- a/Godeps/_workspace/src/github.com/docker/libcompose/project/project.go +++ b/Godeps/_workspace/src/github.com/docker/libcompose/project/project.go @@ -187,7 +187,7 @@ func (p *Project) Up(services ...string) error { func (p *Project) Log(services ...string) error { return p.forEach(services, wrapperAction(func(wrapper *serviceWrapper, wrappers map[string]*serviceWrapper) { - wrapper.Do(nil, "", "", func(service Service) error { + wrapper.Do(nil, NO_EVENT, NO_EVENT, func(service Service) error { return service.Log() }) }), nil) @@ -218,16 +218,11 @@ func (p *Project) Kill(services ...string) error { } func (p *Project) perform(start, done Event, services []string, action wrapperAction, cycleAction serviceAction) error { - if start != "" { - p.Notify(start, "", nil) - } + p.Notify(start, "", nil) err := p.forEach(services, action, cycleAction) - if err == nil && done != "" { - p.Notify(done, "", nil) - } - + p.Notify(done, "", nil) return err } @@ -355,6 +350,10 @@ func (p *Project) AddListener(c chan<- ProjectEvent) { } func (p *Project) Notify(event Event, serviceName string, data map[string]string) { + if event == NO_EVENT { + return + } + projectEvent := ProjectEvent{ Event: event, ServiceName: serviceName, diff --git a/Godeps/_workspace/src/github.com/docker/libcompose/project/project_test.go b/Godeps/_workspace/src/github.com/docker/libcompose/project/project_test.go new file mode 100644 index 00000000..ff4f52cb --- /dev/null +++ b/Godeps/_workspace/src/github.com/docker/libcompose/project/project_test.go @@ -0,0 +1,21 @@ +package project + +import ( + "fmt" + "testing" +) + +func TestEventEquality(t *testing.T) { + if fmt.Sprintf("%s", SERVICE_START) != "Started" || + fmt.Sprintf("%v", SERVICE_START) != "Started" { + t.Fatalf("SERVICE_START String() doesn't work: %s %v", SERVICE_START, SERVICE_START) + } + + if fmt.Sprintf("%s", SERVICE_START) != fmt.Sprintf("%s", SERVICE_UP) { + t.Fatal("Event messages do not match") + } + + if SERVICE_START == SERVICE_UP { + t.Fatal("Events match") + } +} diff --git a/Godeps/_workspace/src/github.com/docker/libcompose/project/service-wrapper.go b/Godeps/_workspace/src/github.com/docker/libcompose/project/service-wrapper.go index 99dda7f0..5fb3317e 100644 --- a/Godeps/_workspace/src/github.com/docker/libcompose/project/service-wrapper.go +++ b/Godeps/_workspace/src/github.com/docker/libcompose/project/service-wrapper.go @@ -95,9 +95,7 @@ func (s *serviceWrapper) Do(wrappers map[string]*serviceWrapper, start, done Eve s.state = EXECUTED - if start != "" { - s.project.Notify(start, s.service.Name(), nil) - } + s.project.Notify(start, s.service.Name(), nil) s.err = action(s.service) if s.err == ErrRestart { @@ -105,7 +103,7 @@ func (s *serviceWrapper) Do(wrappers map[string]*serviceWrapper, start, done Eve s.project.Notify(PROJECT_RELOAD_TRIGGER, s.service.Name(), nil) } else if s.err != nil { log.Errorf("Failed %s %s : %v", start, s.name, s.err) - } else if done != "" { + } else { s.project.Notify(done, s.service.Name(), nil) } } diff --git a/Godeps/_workspace/src/github.com/docker/libcompose/project/types.go b/Godeps/_workspace/src/github.com/docker/libcompose/project/types.go index 9e61a9c2..24032be2 100644 --- a/Godeps/_workspace/src/github.com/docker/libcompose/project/types.go +++ b/Godeps/_workspace/src/github.com/docker/libcompose/project/types.go @@ -1,54 +1,152 @@ package project -type Event string +import "fmt" + +type Event int const ( CONTAINER_ID = "container_id" - CONTAINER_CREATED = Event("Created container") - CONTAINER_STARTED = Event("Started container") + NO_EVENT = Event(iota) - SERVICE_ADD = Event("Adding") - SERVICE_UP_START = Event("Starting") - SERVICE_UP_IGNORED = Event("Ignoring") - SERVICE_UP = Event("Started") - SERVICE_CREATE_START = Event("Creating") - SERVICE_CREATE = Event("Created") - SERVICE_DELETE_START = Event("Deleting") - SERVICE_DELETE = Event("Deleted") - SERVICE_DOWN_START = Event("Stopping") - SERVICE_DOWN = Event("Stopped") - SERVICE_RESTART_START = Event("Restarting") - SERVICE_RESTART = Event("Restarted") - SERVICE_PULL_START = Event("Pulling") - SERVICE_PULL = Event("Pulled") - SERVICE_KILL_START = Event("Killing") - SERVICE_KILL = Event("Killed") - SERVICE_START_START = Event("Starting") - SERVICE_START = Event("Started") - SERVICE_BUILD_START = Event("Building") - SERVICE_BUILD = Event("Built") + CONTAINER_CREATED = Event(iota) + CONTAINER_STARTED = Event(iota) - PROJECT_DOWN_START = Event("Stopping project") - PROJECT_DOWN_DONE = Event("Project stopped") - PROJECT_CREATE_START = Event("Creating project") - PROJECT_CREATE_DONE = Event("Project created") - PROJECT_UP_START = Event("Starting project") - PROJECT_UP_DONE = Event("Project started") - PROJECT_DELETE_START = Event("Deleting project") - PROJECT_DELETE_DONE = Event("Project deleted") - PROJECT_RESTART_START = Event("Restarting project") - PROJECT_RESTART_DONE = Event("Project restarted") - PROJECT_RELOAD = Event("Reloading project") - PROJECT_RELOAD_TRIGGER = Event("Triggering project reload") - PROJECT_KILL_START = Event("Killing project") - PROJECT_KILL_DONE = Event("Project killed") - PROJECT_START_START = Event("Starting project") - PROJECT_START_DONE = Event("Project started") - PROJECT_BUILD_START = Event("Building project") - PROJECT_BUILD_DONE = Event("Project built") + SERVICE_ADD = Event(iota) + SERVICE_UP_START = Event(iota) + SERVICE_UP_IGNORED = Event(iota) + SERVICE_UP = Event(iota) + SERVICE_CREATE_START = Event(iota) + SERVICE_CREATE = Event(iota) + SERVICE_DELETE_START = Event(iota) + SERVICE_DELETE = Event(iota) + SERVICE_DOWN_START = Event(iota) + SERVICE_DOWN = Event(iota) + SERVICE_RESTART_START = Event(iota) + SERVICE_RESTART = Event(iota) + SERVICE_PULL_START = Event(iota) + SERVICE_PULL = Event(iota) + SERVICE_KILL_START = Event(iota) + SERVICE_KILL = Event(iota) + SERVICE_START_START = Event(iota) + SERVICE_START = Event(iota) + SERVICE_BUILD_START = Event(iota) + SERVICE_BUILD = Event(iota) + + PROJECT_DOWN_START = Event(iota) + PROJECT_DOWN_DONE = Event(iota) + PROJECT_CREATE_START = Event(iota) + PROJECT_CREATE_DONE = Event(iota) + PROJECT_UP_START = Event(iota) + PROJECT_UP_DONE = Event(iota) + PROJECT_DELETE_START = Event(iota) + PROJECT_DELETE_DONE = Event(iota) + PROJECT_RESTART_START = Event(iota) + PROJECT_RESTART_DONE = Event(iota) + PROJECT_RELOAD = Event(iota) + PROJECT_RELOAD_TRIGGER = Event(iota) + PROJECT_KILL_START = Event(iota) + PROJECT_KILL_DONE = Event(iota) + PROJECT_START_START = Event(iota) + PROJECT_START_DONE = Event(iota) + PROJECT_BUILD_START = Event(iota) + PROJECT_BUILD_DONE = Event(iota) ) +func (e Event) String() string { + var m string + switch e { + case CONTAINER_CREATED: + m = "Created container" + case CONTAINER_STARTED: + m = "Started container" + + case SERVICE_ADD: + m = "Adding" + case SERVICE_UP_START: + m = "Starting" + case SERVICE_UP_IGNORED: + m = "Ignoring" + case SERVICE_UP: + m = "Started" + case SERVICE_CREATE_START: + m = "Creating" + case SERVICE_CREATE: + m = "Created" + case SERVICE_DELETE_START: + m = "Deleting" + case SERVICE_DELETE: + m = "Deleted" + case SERVICE_DOWN_START: + m = "Stopping" + case SERVICE_DOWN: + m = "Stopped" + case SERVICE_RESTART_START: + m = "Restarting" + case SERVICE_RESTART: + m = "Restarted" + case SERVICE_PULL_START: + m = "Pulling" + case SERVICE_PULL: + m = "Pulled" + case SERVICE_KILL_START: + m = "Killing" + case SERVICE_KILL: + m = "Killed" + case SERVICE_START_START: + m = "Starting" + case SERVICE_START: + m = "Started" + case SERVICE_BUILD_START: + m = "Building" + case SERVICE_BUILD: + m = "Built" + + case PROJECT_DOWN_START: + m = "Stopping project" + case PROJECT_DOWN_DONE: + m = "Project stopped" + case PROJECT_CREATE_START: + m = "Creating project" + case PROJECT_CREATE_DONE: + m = "Project created" + case PROJECT_UP_START: + m = "Starting project" + case PROJECT_UP_DONE: + m = "Project started" + case PROJECT_DELETE_START: + m = "Deleting project" + case PROJECT_DELETE_DONE: + m = "Project deleted" + case PROJECT_RESTART_START: + m = "Restarting project" + case PROJECT_RESTART_DONE: + m = "Project restarted" + case PROJECT_RELOAD: + m = "Reloading project" + case PROJECT_RELOAD_TRIGGER: + m = "Triggering project reload" + case PROJECT_KILL_START: + m = "Killing project" + case PROJECT_KILL_DONE: + m = "Project killed" + case PROJECT_START_START: + m = "Starting project" + case PROJECT_START_DONE: + m = "Project started" + case PROJECT_BUILD_START: + m = "Building project" + case PROJECT_BUILD_DONE: + m = "Project built" + } + + if m == "" { + m = fmt.Sprintf("Event: %d", int(e)) + } + + return m +} + type InfoPart struct { Key, Value string } diff --git a/Godeps/_workspace/src/github.com/rancher/docker-from-scratch/scripts/download b/Godeps/_workspace/src/github.com/rancher/docker-from-scratch/scripts/download index d591f93e..c073f227 100644 --- a/Godeps/_workspace/src/github.com/rancher/docker-from-scratch/scripts/download +++ b/Godeps/_workspace/src/github.com/rancher/docker-from-scratch/scripts/download @@ -47,7 +47,7 @@ else cp assets/base-files.tar.gz build fi -download 342880a7806447539e959df2119580bd56852b24 https://test.docker.com/builds/Linux/x86_64/docker-1.8.0-rc3 +download 9a711e6b98a388b12091cf716c5996b67a2e223a https://get.docker.com/builds/Linux/x86_64/docker-1.8.1 cp assets/docker-* build/docker chmod +x build/docker diff --git a/Godeps/_workspace/src/github.com/rancher/docker-from-scratch/scripts/version b/Godeps/_workspace/src/github.com/rancher/docker-from-scratch/scripts/version index 1298ad0a..a8fdfda1 100644 --- a/Godeps/_workspace/src/github.com/rancher/docker-from-scratch/scripts/version +++ b/Godeps/_workspace/src/github.com/rancher/docker-from-scratch/scripts/version @@ -1 +1 @@ -1.8.0-rc3 +1.8.1