Skip to content

Commit

Permalink
skip pulling if nothing to pull
Browse files Browse the repository at this point in the history
Fixes #87
  • Loading branch information
paulcichonski committed Dec 1, 2017
1 parent 42fb9e5 commit 97e50b2
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
15 changes: 15 additions & 0 deletions blackbox-test/features/bootstrap.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
20 changes: 15 additions & 5 deletions command/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

0 comments on commit 97e50b2

Please sign in to comment.