From 963409e009430e4199b8eb442833521d534b61d0 Mon Sep 17 00:00:00 2001 From: Jordan Singleton Date: Wed, 19 Aug 2015 11:58:44 -0400 Subject: [PATCH] bundles can specify services --- docs/changelog.md | 1 + docs/specs/bundle-specs.md | 11 +++++++++++ dusty/compiler/spec_assembler.py | 6 +++++- dusty/schemas/bundle_schema.py | 3 ++- .../compiler/test_configs/simple/assembled_spec.yml | 4 +++- .../compiler/test_configs/simple/bundles/simple.yml | 2 ++ .../simple/services/bundle-specified-service.yml | 1 + 7 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 tests/unit/compiler/test_configs/simple/services/bundle-specified-service.yml diff --git a/docs/changelog.md b/docs/changelog.md index 71093051..131a57a0 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -8,6 +8,7 @@ * The `restart` command no longer takes a `--no-sync` flag, due to the move to NFS. * **New** * Dusty now attempts to fix a known problem with boot2docker networking, resulting in up to a 10x improvement in network performance. See [this boot2docker issue](https://github.com/boot2docker/boot2docker/issues/1022) for more information. + * Dusty bundles can now specify services, just as they specify apps * **Misc** * `test.once` commands that fail now cause the entire test run to fail immediately. * When running all test suites, a tabular summary of test results is now printed at the end of the run diff --git a/docs/specs/bundle-specs.md b/docs/specs/bundle-specs.md index 74b11c8f..666e6a55 100644 --- a/docs/specs/bundle-specs.md +++ b/docs/specs/bundle-specs.md @@ -28,3 +28,14 @@ apps: The list of apps to be run by `dusty up` if this bundle is activated. These apps are used as entrypoints into the dependency graph defined by your app and service specs. + +## services + +``` +services: + - postgres +``` + +An optional list of services which will be run by `dusty up` if this bundle +is activated. Services specified here will be launched in addition to services +that specified apps depend on. diff --git a/dusty/compiler/spec_assembler.py b/dusty/compiler/spec_assembler.py index 039c749a..07d417f1 100644 --- a/dusty/compiler/spec_assembler.py +++ b/dusty/compiler/spec_assembler.py @@ -67,12 +67,16 @@ def _get_referenced_libs(specs): def _get_referenced_services(specs): """ - Returns all services that are referenced in specs.apps.depends.services + Returns all services that are referenced in specs.apps.depends.services, + or in specs.bundles.services """ active_services = set() for app_spec in specs['apps'].values(): for service in app_spec['depends']['services']: active_services.add(service) + for bundle_spec in specs['bundles'].values(): + for service in bundle_spec['services']: + active_services.add(service) return active_services def _filter_active(spec_type, specs): diff --git a/dusty/schemas/bundle_schema.py b/dusty/schemas/bundle_schema.py index 4ace6084..469397ee 100644 --- a/dusty/schemas/bundle_schema.py +++ b/dusty/schemas/bundle_schema.py @@ -2,5 +2,6 @@ bundle_schema = Schema({ 'description': {'type': basestring, 'default': ''}, - 'apps': {'type': Array(basestring), 'required': True} + 'apps': {'type': Array(basestring), 'required': True}, + 'services': {'type': Array(basestring), 'default': list} }) diff --git a/tests/unit/compiler/test_configs/simple/assembled_spec.yml b/tests/unit/compiler/test_configs/simple/assembled_spec.yml index b62d80cf..60198e36 100644 --- a/tests/unit/compiler/test_configs/simple/assembled_spec.yml +++ b/tests/unit/compiler/test_configs/simple/assembled_spec.yml @@ -18,4 +18,6 @@ apps: libs: [] services: [] libs: {} -services: {} +services: + bundle-specified-service: + image: someimage diff --git a/tests/unit/compiler/test_configs/simple/bundles/simple.yml b/tests/unit/compiler/test_configs/simple/bundles/simple.yml index a2857445..7807ec5f 100644 --- a/tests/unit/compiler/test_configs/simple/bundles/simple.yml +++ b/tests/unit/compiler/test_configs/simple/bundles/simple.yml @@ -1,2 +1,4 @@ apps: - simpleapp +services: + - bundle-specified-service diff --git a/tests/unit/compiler/test_configs/simple/services/bundle-specified-service.yml b/tests/unit/compiler/test_configs/simple/services/bundle-specified-service.yml new file mode 100644 index 00000000..1869d4d2 --- /dev/null +++ b/tests/unit/compiler/test_configs/simple/services/bundle-specified-service.yml @@ -0,0 +1 @@ +image: someimage