def deploy_toolkit( context: "Context", username: Optional[str], password: Optional[str], msg_ctx: MessagesContext, top_level: str = "orbit", ) -> None: credential_received: bool = username is not None and password is not None stack_exist: bool = cfn.does_stack_exist( stack_name=context.toolkit.stack_name) credential_exist: bool = dockerhub.does_credential_exist( context=context) if stack_exist else False image_manifests = [ cast(ImageManifest, getattr(context.images, i)) for i in context.images.names ] credential_required: bool = any([ im.get_source(account_id=context.account_id, region=context.region) == "dockerhub" for im in image_manifests ]) if stack_exist: if credential_required and not credential_exist and not credential_received: username, password = _request_dockerhub_credential(msg_ctx=msg_ctx) dockerhub.store_credential(context=context, username=username, password=password) credential_exist = True elif credential_received: dockerhub.store_credential( context=context, username=cast(str, username), password=cast(str, password), ) credential_exist = True else: context.toolkit.deploy_id = "".join( random.choice(string.ascii_lowercase) for i in range(6)) if credential_required and not credential_received: username, password = _request_dockerhub_credential(msg_ctx=msg_ctx) credential_exist = False msg_ctx.progress(6) _logger.debug("context.toolkit.deploy_id: %s", context.toolkit.deploy_id) template_filename: str = toolkit.synth(context=context, top_level=top_level) cfn.deploy_template(stack_name=context.toolkit.stack_name, filename=template_filename, env_tag=context.env_tag, s3_bucket=None) ContextSerDe.fetch_toolkit_data(context=context) ContextSerDe.dump_context_to_ssm(context=context) if credential_exist is False: dockerhub.store_credential( context=context, username=cast(str, username), password=cast(str, password), )
def _deploy_toolkit( context: "Context", top_level: str = "orbit", ) -> None: stack_exist: bool = cfn.does_stack_exist(stack_name=context.toolkit.stack_name) if not stack_exist: context.toolkit.deploy_id = "".join(random.choice(string.ascii_lowercase) for i in range(6)) _logger.debug("context.toolkit.deploy_id: %s", context.toolkit.deploy_id) template_filename: str = toolkit.synth(context=context, top_level=top_level) cfn.deploy_template( stack_name=context.toolkit.stack_name, filename=template_filename, env_tag=context.env_tag, s3_bucket=None ) ContextSerDe.fetch_toolkit_data(context=context) ContextSerDe.dump_context_to_ssm(context=context)