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:
Mazz Mosley
2015-08-26 13:23:29 +01:00
parent 36757cde1c
commit 4a8b2947ca
5 changed files with 50 additions and 21 deletions

View File

@@ -0,0 +1,3 @@
web:
build: '.'
hostname: "host-${HOSTNAME_VALUE}"

View File

@@ -0,0 +1,5 @@
myweb:
extends:
service: web
file: valid-interpolation-2.yml
command: top

View File

@@ -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')