From 97e50b2a4eb6c58ff23c0d693d70ec0f078abdfc Mon Sep 17 00:00:00 2001 From: Paul Cichonski Date: Fri, 1 Dec 2017 14:33:52 -0500 Subject: [PATCH] skip pulling if nothing to pull Fixes #87 --- CHANGELOG.md | 3 +++ blackbox-test/features/bootstrap.feature | 15 +++++++++++++++ command/bootstrap.go | 20 +++++++++++++++----- 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2a4e3a6..5748ad1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ ## Unreleased +- Fix [issue](https://github.com/cisco/elsy/issues/87) where a docker-compose +containing only services using local images would break bootstrapping. + ## v3.1.0 - Add support for a `local_images` config in `lc.yml`. Images listed in this diff --git a/blackbox-test/features/bootstrap.feature b/blackbox-test/features/bootstrap.feature index 2c6dcdc..bd7cae0 100644 --- a/blackbox-test/features/bootstrap.feature +++ b/blackbox-test/features/bootstrap.feature @@ -123,6 +123,21 @@ Feature: bootstrap task When I run `lc bootstrap` Then it should succeed + ## https://github.com/cisco/elsy/issues/87 + Scenario: with services only using local images + Given a file named "docker-compose.yml" with: + """yaml + prodserver: + image: bazzer + """ + And a file named "lc.yml" with: + """yaml + name: testbootstrap + docker_image_name: bazzer + """ + When I run `lc bootstrap` + Then it should succeed + Scenario: running in offline mode If we run with --offline, we should not try to pull any images. Given a file named "docker-compose.yml" with: diff --git a/command/bootstrap.go b/command/bootstrap.go index 8fe5ba7..9014ca0 100644 --- a/command/bootstrap.go +++ b/command/bootstrap.go @@ -38,20 +38,30 @@ func CmdBootstrap(c *cli.Context) error { args = append(args, "pull", "--parallel") } + var skipPull bool if c.String("docker-image-name") != "" || len(c.StringSlice("local-images")) > 0 { excludes := c.StringSlice("local-images") if c.String("docker-image-name") != "" { excludes = append(excludes, c.String("docker-image-name")) } logrus.WithField("docker-image-name", excludes).Debug("not pulling services using repo's docker artifact") - args = append(args, helpers.DockerComposeServicesExcluding(excludes)...) + + services := helpers.DockerComposeServicesExcluding(excludes) + if len(services) == 0 { + skipPull = true + logrus.Debug("no services to pull") + } else { + args = append(args, services...) + } } - pullCmd := helpers.DockerComposeCommand(args...) - if err := helpers.RunCommand(pullCmd); err != nil { - return err + if !skipPull { + pullCmd := helpers.DockerComposeCommand(args...) + if err := helpers.RunCommand(pullCmd); err != nil { + return err + } } - } + } return CmdInstallDependencies(c) }