From 1d1e23611b4e8caf87d6d2601bc8ee1e81d7e5db Mon Sep 17 00:00:00 2001 From: d11wtq Date: Sun, 8 Jun 2014 23:20:51 +0000 Subject: [PATCH] Rename --keep-old to --no-recreate Signed-off-by: Chris Corbyn --- docs/cli.md | 2 +- fig/cli/main.py | 16 ++++++++-------- fig/project.py | 8 ++++---- tests/integration/cli_test.py | 2 +- tests/integration/project_test.py | 8 ++++---- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/docs/cli.md b/docs/cli.md index 3d5871ad3..5e99e8341 100644 --- a/docs/cli.md +++ b/docs/cli.md @@ -82,6 +82,6 @@ Linked services will be started, unless they are already running. By default, `fig up` will aggregate the output of each container, and when it exits, all containers will be stopped. If you run `fig up -d`, it'll start the containers in the background and leave them running. -By default if there are existing containers for a service, `fig up` will stop and recreate them (preserving mounted volumes with [volumes-from]), so that changes in `fig.yml` are picked up. If you do no want containers to be stopped and recreated, use `fig up --keep-old`. This will still start any stopped containers, if needed. +By default if there are existing containers for a service, `fig up` will stop and recreate them (preserving mounted volumes with [volumes-from]), so that changes in `fig.yml` are picked up. If you do no want containers to be stopped and recreated, use `fig up --no-recreate`. This will still start any stopped containers, if needed. [volumes-from]: http://docs.docker.io/en/latest/use/working_with_volumes/ diff --git a/fig/cli/main.py b/fig/cli/main.py index 6c00cb493..cfb6a7782 100644 --- a/fig/cli/main.py +++ b/fig/cli/main.py @@ -223,7 +223,7 @@ class TopLevelCommand(Command): self.project.up( service_names=service.get_linked_names(), start_links=True, - keep_old=True + recreate=False ) tty = True @@ -303,27 +303,27 @@ class TopLevelCommand(Command): If there are existing containers for a service, `fig up` will stop and recreate them (preserving mounted volumes with volumes-from), so that changes in `fig.yml` are picked up. If you do not want existing - containers to be recreated, `fig up --keep-old` will re-use existing + containers to be recreated, `fig up --no-recreate` will re-use existing containers. Usage: up [options] [SERVICE...] Options: - -d Detached mode: Run containers in the background, print - new container names. - --no-links Don't start linked services. - --keep-old If containers already exist, don't recreate them. + -d Detached mode: Run containers in the background, + print new container names. + --no-links Don't start linked services. + --no-recreate If containers already exist, don't recreate them. """ detached = options['-d'] start_links = not options['--no-links'] - keep_old = options['--keep-old'] + recreate = not options['--no-recreate'] service_names = options['SERVICE'] to_attach = self.project.up( service_names=service_names, start_links=start_links, - keep_old=keep_old + recreate=recreate ) if not detached: diff --git a/fig/project.py b/fig/project.py index 5c798d384..5e2b1fccb 100644 --- a/fig/project.py +++ b/fig/project.py @@ -138,15 +138,15 @@ class Project(object): else: log.info('%s uses an image, skipping' % service.name) - def up(self, service_names=None, start_links=True, keep_old=False): + def up(self, service_names=None, start_links=True, recreate=True): running_containers = [] for service in self.get_services(service_names, include_links=start_links): - if keep_old: - for container in service.start_or_create_containers(): + if recreate: + for (_, container) in service.recreate_containers(): running_containers.append(container) else: - for (_, container) in service.recreate_containers(): + for container in service.start_or_create_containers(): running_containers.append(container) return running_containers diff --git a/tests/integration/cli_test.py b/tests/integration/cli_test.py index 1000e8dab..ba309ef16 100644 --- a/tests/integration/cli_test.py +++ b/tests/integration/cli_test.py @@ -94,7 +94,7 @@ class CLITestCase(DockerClientTestCase): old_ids = [c.id for c in service.containers()] - self.command.dispatch(['up', '-d', '--keep-old'], None) + self.command.dispatch(['up', '-d', '--no-recreate'], None) self.assertEqual(len(service.containers()), 1) new_ids = [c.id for c in service.containers()] diff --git a/tests/integration/project_test.py b/tests/integration/project_test.py index 0c5c1aa76..dcca570b2 100644 --- a/tests/integration/project_test.py +++ b/tests/integration/project_test.py @@ -74,7 +74,7 @@ class ProjectTest(DockerClientTestCase): project.kill() project.remove_stopped() - def test_project_up_with_keep_old_running(self): + def test_project_up_with_no_recreate_running(self): web = self.create_service('web') db = self.create_service('db', volumes=['/var/db']) project = Project('figtest', [web, db], self.client) @@ -86,7 +86,7 @@ class ProjectTest(DockerClientTestCase): old_db_id = project.containers()[0].id db_volume_path = project.containers()[0].inspect()['Volumes']['/var/db'] - project.up(keep_old=True) + project.up(recreate=False) self.assertEqual(len(project.containers()), 2) db_container = [c for c in project.containers() if 'db' in c.name][0] @@ -96,7 +96,7 @@ class ProjectTest(DockerClientTestCase): project.kill() project.remove_stopped() - def test_project_up_with_keep_old_stopped(self): + def test_project_up_with_no_recreate_stopped(self): web = self.create_service('web') db = self.create_service('db', volumes=['/var/db']) project = Project('figtest', [web, db], self.client) @@ -112,7 +112,7 @@ class ProjectTest(DockerClientTestCase): old_db_id = old_containers[0].id db_volume_path = old_containers[0].inspect()['Volumes']['/var/db'] - project.up(keep_old=True) + project.up(recreate=False) new_containers = project.containers(stopped=True) self.assertEqual(len(new_containers), 2)