def deploy(
    plugin_id: str,
    context: "Context",
    team_context: "TeamContext",
    parameters: Dict[str, Any],
) -> None:
    _logger.debug("Team Env name: %s | Team name: %s", context.name,
                  team_context.name)
    plugin_id = plugin_id.replace("_", "-")
    _logger.debug("plugin_id: %s", plugin_id)
    if parameters.get("scope", "deploy") == "deploy":
        repo = team_context.name
        chart_name, chart_version, chart_package = helm_package(
            plugin_id, context, team_context, parameters)

        release_name = f"{team_context.name}-{plugin_id}".replace("_", "-")
        if helm.is_exists_chart_release(release_name, team_context.name):
            helm.uninstall_chart(release_name, team_context.name)
            time.sleep(60)

        helm.install_chart_no_upgrade(
            repo=repo,
            namespace=team_context.name,
            name=release_name,
            chart_name=chart_name,
            chart_version=chart_version,
        )
    else:
        _logger.debug("Skipping plugin deploy hook")
Пример #2
0
def destroy(
    plugin_id: str,
    context: "Context",
    team_context: "TeamContext",
    parameters: Dict[str, Any],
) -> None:
    _logger.debug(
        "Delete Plugin %s of Team Env name: %s | Team name: %s",
        plugin_id,
        context.name,
        team_context.name,
    )
    helm.uninstall_chart(f"{team_context.name}-{plugin_id}", namespace=team_context.name)
def destroy(
    plugin_id: str,
    context: "Context",
    team_context: "TeamContext",
    parameters: Dict[str, Any],
) -> None:
    plugin_id = plugin_id.replace("_", "-")
    _logger.debug(
        "Delete Plugin %s of Team Env name: %s | Team name: %s",
        plugin_id,
        context.name,
        team_context.name,
    )
    release_name = f"{team_context.name}-{plugin_id}"
    try:
        helm.uninstall_chart(release_name, namespace=team_context.name)
    except Exception as e:
        _logger.error(str(e))
def destroy(
    plugin_id: str,
    context: "Context",
    team_context: "TeamContext",
    parameters: Dict[str, Any],
) -> None:
    plugin_id = plugin_id.replace("_", "-")
    _logger.debug(
        "Delete Plugin %s of Team Env name: %s | Team name: %s",
        plugin_id,
        context.name,
        team_context.name,
    )
    release_name = f"{team_context.name}-{plugin_id}".replace("_", "-")

    if "scope" in parameters and parameters["scope"] == "destroy":
        # Create new chart, release and respective job
        repo = team_context.name
        chart_name, chart_version, chart_package = helm_package(
            plugin_id, context, team_context, parameters)

        if helm.is_exists_chart_release(release_name, team_context.name):
            helm.uninstall_chart(release_name, team_context.name)
            time.sleep(60)

        if ns_exists(team_context=team_context):
            helm.install_chart_no_upgrade(
                repo=repo,
                namespace=team_context.name,
                name=release_name,
                chart_name=chart_name,
                chart_version=chart_version,
            )
            # wait for job completion
            try:
                sh.run(
                    f"kubectl wait --for=condition=complete "
                    f"--timeout=120s job/{plugin_id} --namespace {team_context.name}"
                )
            except Exception as e:
                _logger.error(e)

        # destroy
        helm.uninstall_chart(release_name, namespace=team_context.name)
        return

    # For Deploy Scope
    helm.uninstall_chart(release_name, namespace=team_context.name)