4b6817381b
CI (OpenClaw E2E) / openclaw test (push) Has been cancelled
CI / coverage-report (push) Has been cancelled
CI / test-kubernetes (push) Has been cancelled
CI / should-run-thorough (push) Has been cancelled
CI / test-thorough (cloudwatch-demo) (push) Has been cancelled
CI / test-thorough (flink-ecs) (push) Has been cancelled
CI / test-thorough (upstream-lambda) (push) Has been cancelled
CI / test-thorough (prefect-ecs-fargate) (push) Has been cancelled
Release / build-binaries (zip, opensre.exe, onefile, windows-latest, windows-x64) (push) Has been cancelled
Benchmark image — build + push to ECR (any adapter) / build + push (push) Has been cancelled
CI / quality (ubuntu-latest) (push) Has been cancelled
CI / test (tools-runtime) (push) Has been cancelled
CI / test (e2e-general) (push) Has been cancelled
CI / test (cli-runtime) (push) Has been cancelled
CI / test (e2e-provider-and-openclaw) (push) Has been cancelled
CI / test (integrations-and-misc) (push) Has been cancelled
Release / verify (push) Has been cancelled
Release / build-python-dist (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, macos-15-intel, darwin-x64) (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, macos-latest, darwin-arm64) (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, ubuntu-22.04, linux-x64) (push) Has been cancelled
Release / publish-release (push) Has been cancelled
Release / publish-main-release (push) Has been cancelled
Interactive Shell Live (PR + post-merge) / turn-checks (no-LLM) (push) Has been cancelled
CodeQL / Analyze (python) (push) Has been cancelled
Interactive Shell Live (PR + post-merge) / turn-live shard ${{ matrix.shard_index }} (push) Has been cancelled
Release / prepare (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, ubuntu-22.04-arm, linux-arm64) (push) Has been cancelled
Synthetic Deterministic Tests / Synthetic offline (deterministic) (push) Has been cancelled
87 lines
2.2 KiB
Python
87 lines
2.2 KiB
Python
"""kubectl / helm subprocess helpers with optional context."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import subprocess
|
|
from collections.abc import Sequence
|
|
from pathlib import Path
|
|
|
|
|
|
def kubectl_base(context: str | None) -> list[str]:
|
|
cmd = ["kubectl"]
|
|
if context:
|
|
cmd.extend(["--context", context])
|
|
return cmd
|
|
|
|
|
|
def kubectl_apply(manifest: Path | str, *, context: str | None) -> None:
|
|
path = Path(manifest) if isinstance(manifest, str) else manifest
|
|
subprocess.run(
|
|
[*kubectl_base(context), "apply", "-f", str(path)],
|
|
check=True,
|
|
)
|
|
|
|
|
|
def kubectl_delete(manifest: Path | str, *, context: str | None) -> None:
|
|
path = Path(manifest) if isinstance(manifest, str) else manifest
|
|
subprocess.run(
|
|
[*kubectl_base(context), "delete", "-f", str(path), "--ignore-not-found"],
|
|
check=False,
|
|
)
|
|
|
|
|
|
def kubectl_create_namespace(name: str, *, context: str | None) -> None:
|
|
p_create = subprocess.run(
|
|
[
|
|
*kubectl_base(context),
|
|
"create",
|
|
"namespace",
|
|
name,
|
|
"--dry-run=client",
|
|
"-o",
|
|
"yaml",
|
|
],
|
|
check=True,
|
|
capture_output=True,
|
|
)
|
|
subprocess.run(
|
|
[*kubectl_base(context), "apply", "-f", "-"],
|
|
check=True,
|
|
input=p_create.stdout,
|
|
)
|
|
|
|
|
|
def helm_upgrade_install(
|
|
*,
|
|
release: str,
|
|
chart: str,
|
|
namespace: str,
|
|
extra_args: Sequence[str],
|
|
kube_context: str | None,
|
|
) -> None:
|
|
cmd = [
|
|
"helm",
|
|
"upgrade",
|
|
"--install",
|
|
release,
|
|
chart,
|
|
"-n",
|
|
namespace,
|
|
*extra_args,
|
|
]
|
|
if kube_context:
|
|
cmd.extend(["--kube-context", kube_context])
|
|
subprocess.run(cmd, check=True)
|
|
|
|
|
|
def helm_uninstall(release: str, *, namespace: str, kube_context: str | None) -> None:
|
|
cmd = ["helm", "uninstall", release, "-n", namespace]
|
|
if kube_context:
|
|
cmd.extend(["--kube-context", kube_context])
|
|
subprocess.run(cmd, check=False)
|
|
|
|
|
|
def helm_repo_add(name: str, url: str) -> None:
|
|
subprocess.run(["helm", "repo", "add", name, url], check=False)
|
|
subprocess.run(["helm", "repo", "update"], check=True)
|