Rename --keep-old to --no-recreate

Signed-off-by: Chris Corbyn <chris@w3style.co.uk>
This commit is contained in:
d11wtq 2014-06-08 23:20:51 +00:00 committed by Chris Corbyn
parent 74e067c6e6
commit 1d1e23611b
5 changed files with 18 additions and 18 deletions

View File

@ -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, `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/ [volumes-from]: http://docs.docker.io/en/latest/use/working_with_volumes/

View File

@ -223,7 +223,7 @@ class TopLevelCommand(Command):
self.project.up( self.project.up(
service_names=service.get_linked_names(), service_names=service.get_linked_names(),
start_links=True, start_links=True,
keep_old=True recreate=False
) )
tty = True tty = True
@ -303,27 +303,27 @@ class TopLevelCommand(Command):
If there are existing containers for a service, `fig up` will stop If there are existing containers for a service, `fig up` will stop
and recreate them (preserving mounted volumes with volumes-from), and recreate them (preserving mounted volumes with volumes-from),
so that changes in `fig.yml` are picked up. If you do not want existing 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. containers.
Usage: up [options] [SERVICE...] Usage: up [options] [SERVICE...]
Options: Options:
-d Detached mode: Run containers in the background, print -d Detached mode: Run containers in the background,
new container names. print new container names.
--no-links Don't start linked services. --no-links Don't start linked services.
--keep-old If containers already exist, don't recreate them. --no-recreate If containers already exist, don't recreate them.
""" """
detached = options['-d'] detached = options['-d']
start_links = not options['--no-links'] start_links = not options['--no-links']
keep_old = options['--keep-old'] recreate = not options['--no-recreate']
service_names = options['SERVICE'] service_names = options['SERVICE']
to_attach = self.project.up( to_attach = self.project.up(
service_names=service_names, service_names=service_names,
start_links=start_links, start_links=start_links,
keep_old=keep_old recreate=recreate
) )
if not detached: if not detached:

View File

@ -138,15 +138,15 @@ class Project(object):
else: else:
log.info('%s uses an image, skipping' % service.name) 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 = [] running_containers = []
for service in self.get_services(service_names, include_links=start_links): for service in self.get_services(service_names, include_links=start_links):
if keep_old: if recreate:
for container in service.start_or_create_containers(): for (_, container) in service.recreate_containers():
running_containers.append(container) running_containers.append(container)
else: else:
for (_, container) in service.recreate_containers(): for container in service.start_or_create_containers():
running_containers.append(container) running_containers.append(container)
return running_containers return running_containers

View File

@ -94,7 +94,7 @@ class CLITestCase(DockerClientTestCase):
old_ids = [c.id for c in service.containers()] 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) self.assertEqual(len(service.containers()), 1)
new_ids = [c.id for c in service.containers()] new_ids = [c.id for c in service.containers()]

View File

@ -74,7 +74,7 @@ class ProjectTest(DockerClientTestCase):
project.kill() project.kill()
project.remove_stopped() 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') web = self.create_service('web')
db = self.create_service('db', volumes=['/var/db']) db = self.create_service('db', volumes=['/var/db'])
project = Project('figtest', [web, db], self.client) project = Project('figtest', [web, db], self.client)
@ -86,7 +86,7 @@ class ProjectTest(DockerClientTestCase):
old_db_id = project.containers()[0].id old_db_id = project.containers()[0].id
db_volume_path = project.containers()[0].inspect()['Volumes']['/var/db'] 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) self.assertEqual(len(project.containers()), 2)
db_container = [c for c in project.containers() if 'db' in c.name][0] db_container = [c for c in project.containers() if 'db' in c.name][0]
@ -96,7 +96,7 @@ class ProjectTest(DockerClientTestCase):
project.kill() project.kill()
project.remove_stopped() 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') web = self.create_service('web')
db = self.create_service('db', volumes=['/var/db']) db = self.create_service('db', volumes=['/var/db'])
project = Project('figtest', [web, db], self.client) project = Project('figtest', [web, db], self.client)
@ -112,7 +112,7 @@ class ProjectTest(DockerClientTestCase):
old_db_id = old_containers[0].id old_db_id = old_containers[0].id
db_volume_path = old_containers[0].inspect()['Volumes']['/var/db'] 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) new_containers = project.containers(stopped=True)
self.assertEqual(len(new_containers), 2) self.assertEqual(len(new_containers), 2)