示例#1
0
def render_pipeline(
        definition_file: CliHints.existing_file(),
        template_path: CliHints.existing_dir(),
        cfg_name: str,
        out_dir: CliHints.existing_dir(),
        template_include_dir: str = None,
):
    cfg_factory = ctx().cfg_factory()
    cfg_set = cfg_factory.cfg_set(cfg_name=cfg_name)

    def_enumerators = [
        SimpleFileDefinitionEnumerator(
            definition_file=definition_file,
            cfg_set=cfg_set,
            repo_path='example/example',
            repo_branch='master',
            repo_host='github.com',
        )
    ]

    preprocessor = DefinitionDescriptorPreprocessor()

    if not template_include_dir:
        template_include_dir = template_path

    template_retriever = TemplateRetriever(template_path=template_path)
    renderer = Renderer(
        template_retriever=template_retriever,
        template_include_dir=template_include_dir,
        cfg_set=cfg_set,
    )

    deployer = FilesystemDeployer(base_dir=out_dir)

    replicator = PipelineReplicator(definition_enumerators=def_enumerators,
                                    descriptor_preprocessor=preprocessor,
                                    definition_renderer=renderer,
                                    definition_deployer=deployer)

    replicator.replicate()