mirror of
https://github.com/docker/docs.git
synced 2026-04-12 06:19:22 +07:00
Interpolate extended config
This refactoring is now really coming together. Construction is happening in the __init__, which is a constructor and helps clean up the design and clarity of intent of the code. We can now see (nearly) everything that is being constructed when a ServiceLoader is created. It needs all of these data constructs to perform the domain logic and actions. Which are now clearer to see and moving more towards the principle of functions doing (mostly)one thing and function names being more descriptive. resolve_extends is now concerned with the resolving of extends, rather than the construction, validation, pre processing and *then* resolving of extends. Happy days :) Signed-off-by: Mazz Mosley <mazz@houseofmnowster.com>
This commit is contained in:
3
tests/fixtures/extends/valid-interpolation-2.yml
vendored
Normal file
3
tests/fixtures/extends/valid-interpolation-2.yml
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
web:
|
||||
build: '.'
|
||||
hostname: "host-${HOSTNAME_VALUE}"
|
||||
5
tests/fixtures/extends/valid-interpolation.yml
vendored
Normal file
5
tests/fixtures/extends/valid-interpolation.yml
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
myweb:
|
||||
extends:
|
||||
service: web
|
||||
file: valid-interpolation-2.yml
|
||||
command: top
|
||||
@@ -914,6 +914,17 @@ class ExtendsTest(unittest.TestCase):
|
||||
with self.assertRaisesRegexp(ConfigurationError, expected_error_msg):
|
||||
load_from_filename('tests/fixtures/extends/invalid-net.yml')
|
||||
|
||||
@mock.patch.dict(os.environ)
|
||||
def test_valid_interpolation_in_extended_service(self):
|
||||
os.environ.update(
|
||||
HOSTNAME_VALUE="penguin",
|
||||
)
|
||||
expected_interpolated_value = "host-penguin"
|
||||
|
||||
service_dicts = load_from_filename('tests/fixtures/extends/valid-interpolation.yml')
|
||||
for service in service_dicts:
|
||||
self.assertTrue(service['hostname'], expected_interpolated_value)
|
||||
|
||||
def test_volume_path(self):
|
||||
dicts = load_from_filename('tests/fixtures/volume-path/docker-compose.yml')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user