Ejemplo n.º 1
0
def deploy_dry_run(
    dst_project,
    sets,
    all_services,
    env_values,
    env_files,
    template_dir,
    scale_resources,
    pick,
    skip,
    output,
    to_dir,
):
    template_dir, env_config_handler, specific_components, sets_selected, _ = _parse_args(
        template_dir, env_values, env_files, all_services, sets, pick, dst_project
    )

    # No need to set up SecretImporter, it won't be used in a dry run

    DeployRunner(
        template_dir,
        dst_project,
        env_config_handler,
        ignore_requires=True,  # ignore for a dry run
        service_sets_selected=sets_selected,
        resources_scale_factor=scale_resources,
        root_custom_dir=None,  # won't be used in a dry run
        specific_components=specific_components,
        label=None,
        skip=skip.split(",") if skip else None,
        dry_run=True,
        dry_run_opts={"output": output, "to_dir": to_dir},
    ).run()
Ejemplo n.º 2
0
def patched_runner(env_values, mock_load_vars_per_env, legacy=False):
    if not env_values:
        handler = None
    elif legacy:
        handler = LegacyEnvConfigHandler(env_files=env_values)
    else:
        handler = EnvConfigHandler(env_names=env_values,
                                   env_dir_name="envTEST")

    runner = DeployRunner(None, "test-project", handler, None, None, None,
                          None)
    runner.base_env_path = "base/envTEST"

    if handler:
        runner.env_config_handler._load_vars_per_env = mock_load_vars_per_env
    return runner
Ejemplo n.º 3
0
def deploy_to_project(
    dst_project,
    no_confirm,
    secrets_local_dir,
    sets,
    all_services,
    secrets_src_project,
    env_files,
    template_dir,
    ignore_requires,
    scale_resources,
    custom_dir,
    pick,
    label,
    skip,
):
    if not custom_dir:
        path = appdirs_path / "custom"
        custom_dir = path if path.exists() else pathlib.Path(
            pathlib.os.getcwd()) / "custom"

    if not secrets_local_dir:
        path = appdirs_path / "secrets"
        secrets_local_dir = path if path.exists() else pathlib.Path(
            pathlib.os.getcwd()) / "secrets"

    if not dst_project:
        log.error("Error: no destination project given")
        sys.exit(1)

    verify_label(label)

    SecretImporter.local_dir = secrets_local_dir
    SecretImporter.source_project = secrets_src_project

    template_dir, specific_component, sets_selected, variables_data, confirm_msg = _parse_common_args(
        template_dir, all_services, sets, pick, dst_project, env_files)

    if not no_confirm and not prompter.yesno(confirm_msg):
        log.info("Aborted by user")
        sys.exit(0)

    switch_to_project(dst_project)

    DeployRunner(
        template_dir,
        dst_project,
        variables_data,
        ignore_requires=ignore_requires,
        service_sets_selected=sets_selected,
        resources_scale_factor=scale_resources,
        custom_dir=custom_dir,
        specific_component=specific_component,
        label=label,
        skip=skip.split(",") if skip else None,
        dry_run=False,
    ).run()

    list_routes(dst_project)
Ejemplo n.º 4
0
def deploy_to_project(
    dst_project,
    no_confirm,
    secrets_local_dir,
    sets,
    all_services,
    secrets_src_project,
    env_values,
    env_files,
    template_dir,
    ignore_requires,
    scale_resources,
    root_custom_dir,
    pick,
    label,
    skip,
    watch,
    concurrent,
    threadpool_size,
):
    root_custom_dir = get_dir(root_custom_dir,
                              "custom",
                              "custom scripts",
                              optional=True)

    if not dst_project:
        log.error("Error: no destination project given")
        sys.exit(1)

    verify_label(label)

    if secrets_local_dir:
        SecretImporter.local_dir = get_dir(secrets_local_dir,
                                           "secrets",
                                           "secrets",
                                           optional=True)
    if secrets_src_project:
        SecretImporter.source_project = secrets_src_project

    template_dir, env_config_handler, specific_components, sets_selected, confirm_msg = _parse_args(
        template_dir, env_values, env_files, all_services, sets, pick,
        dst_project)

    if not no_confirm and not prompter.yesno(confirm_msg):
        log.info("Aborted by user")
        sys.exit(0)

    switch_to_project(dst_project)

    if watch:
        event_watcher = start_event_watcher(dst_project)

    DeployRunner(
        template_dir,
        dst_project,
        env_config_handler,
        ignore_requires=ignore_requires,
        service_sets_selected=sets_selected,
        resources_scale_factor=scale_resources,
        root_custom_dir=root_custom_dir,
        specific_components=specific_components,
        label=label,
        skip=skip.split(",") if skip else None,
        dry_run=False,
        concurrent=concurrent,
        threadpool_size=threadpool_size,
    ).run()

    if watch and event_watcher:
        event_watcher.stop()

    list_routes(dst_project)