Support a default docker-compose.override.yml for overrides
Signed-off-by: Daniel Nephin <dnephin@docker.com>
This commit is contained in:
parent
fe5daf860d
commit
39ae85db8a
6 changed files with 76 additions and 7 deletions
6
tests/fixtures/override-files/docker-compose.override.yml
vendored
Normal file
6
tests/fixtures/override-files/docker-compose.override.yml
vendored
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
|
||||
web:
|
||||
command: "top"
|
||||
|
||||
db:
|
||||
command: "top"
|
||||
10
tests/fixtures/override-files/docker-compose.yml
vendored
Normal file
10
tests/fixtures/override-files/docker-compose.yml
vendored
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
|
||||
web:
|
||||
image: busybox:latest
|
||||
command: "sleep 200"
|
||||
links:
|
||||
- db
|
||||
|
||||
db:
|
||||
image: busybox:latest
|
||||
command: "sleep 200"
|
||||
9
tests/fixtures/override-files/extra.yml
vendored
Normal file
9
tests/fixtures/override-files/extra.yml
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
|
||||
web:
|
||||
links:
|
||||
- db
|
||||
- other
|
||||
|
||||
other:
|
||||
image: busybox:latest
|
||||
command: "top"
|
||||
|
|
@ -549,7 +549,6 @@ class CLITestCase(DockerClientTestCase):
|
|||
self.assertEqual(get_port(3002), "0.0.0.0:49153")
|
||||
|
||||
def test_port_with_scale(self):
|
||||
|
||||
self.command.base_dir = 'tests/fixtures/ports-composefile-scale'
|
||||
self.command.dispatch(['scale', 'simple=2'], None)
|
||||
containers = sorted(
|
||||
|
|
@ -593,6 +592,44 @@ class CLITestCase(DockerClientTestCase):
|
|||
self.assertTrue(components[-2:] == ['home-dir', 'my-volume'],
|
||||
msg="Last two components differ: %s, %s" % (actual_host_path, expected_host_path))
|
||||
|
||||
def test_up_with_default_override_file(self):
|
||||
self.command.base_dir = 'tests/fixtures/override-files'
|
||||
self.command.dispatch(['up', '-d'], None)
|
||||
|
||||
containers = self.project.containers()
|
||||
self.assertEqual(len(containers), 2)
|
||||
|
||||
web, db = containers
|
||||
self.assertEqual(web.human_readable_command, 'top')
|
||||
self.assertEqual(db.human_readable_command, 'top')
|
||||
|
||||
def test_up_with_multiple_files(self):
|
||||
self.command.base_dir = 'tests/fixtures/override-files'
|
||||
config_paths = [
|
||||
'docker-compose.yml',
|
||||
'docker-compose.override.yml',
|
||||
'extra.yml',
|
||||
|
||||
]
|
||||
self._project = get_project(self.command.base_dir, config_paths)
|
||||
self.command.dispatch(
|
||||
[
|
||||
'-f', config_paths[0],
|
||||
'-f', config_paths[1],
|
||||
'-f', config_paths[2],
|
||||
'up', '-d',
|
||||
],
|
||||
None)
|
||||
|
||||
containers = self.project.containers()
|
||||
self.assertEqual(len(containers), 3)
|
||||
|
||||
web, other, db = containers
|
||||
self.assertEqual(web.human_readable_command, 'top')
|
||||
self.assertTrue({'db', 'other'} <= set(web.links()))
|
||||
self.assertEqual(db.human_readable_command, 'top')
|
||||
self.assertEqual(other.human_readable_command, 'top')
|
||||
|
||||
def test_up_with_extends(self):
|
||||
self.command.base_dir = 'tests/fixtures/extends'
|
||||
self.command.dispatch(['up', '-d'], None)
|
||||
|
|
|
|||
|
|
@ -1213,6 +1213,7 @@ def get_config_filename_for_files(filenames, subdir=None):
|
|||
base_dir = tempfile.mkdtemp(dir=project_dir)
|
||||
else:
|
||||
base_dir = project_dir
|
||||
return os.path.basename(config.get_config_path(base_dir))
|
||||
filename, = config.get_default_config_files(base_dir)
|
||||
return os.path.basename(filename)
|
||||
finally:
|
||||
shutil.rmtree(project_dir)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue