diff --git a/cloudlift/__init__.py b/cloudlift/__init__.py index 3c7e4adf..e4c2b6ab 100644 --- a/cloudlift/__init__.py +++ b/cloudlift/__init__.py @@ -113,8 +113,9 @@ def edit_config(name, environment): @click.option("--build-arg", type=(str, str), multiple=True, help="These args are passed to docker build command " "as --build-args. Supports multiple.\ Please leave space between name and value" ) -def deploy_service(name, environment, version, build_arg): - ServiceUpdater(name, environment, None, version, dict(build_arg)).run() +@click.option('--component', help='nested service name', multiple=True) +def deploy_service(name, environment, version, build_arg, component): + ServiceUpdater(name, environment, None, version, dict(build_arg)).run(list(component)) @cli.command() diff --git a/cloudlift/deployment/service_updater.py b/cloudlift/deployment/service_updater.py index c8e626d0..3ceeee58 100644 --- a/cloudlift/deployment/service_updater.py +++ b/cloudlift/deployment/service_updater.py @@ -37,9 +37,16 @@ def __init__(self, name, environment, env_sample_file, version=None, self.working_dir = working_dir self.build_args = build_args - def run(self): + def run(self, component=None): log_warning("Deploying to {self.region}".format(**locals())) self.init_stack_info() + if component is not None: + found = [str for str in self.ecs_service_names if any(sub in str for sub in component)] + self.ecs_service_names = found + if not found: + raise UnrecoverableException("Component {component} not found in service {self.name}".format(**locals())) + elif len(found) != 0 and len(found) != len(component): + log_warning("Few Component {found} found in service {self.name}".format(**locals())) if not os.path.exists(self.env_sample_file): raise UnrecoverableException('env.sample not found. Exiting.') ecr_client = EcrClient(self.name, self.region, self.build_args)