Execution
Running commands and containers from a script. Each function lists its parameters, defaults and return value.
Shell Namespace
Section titled “Shell Namespace”Local shell execution functions.
Scope: System
Functions
Section titled “Functions”| Function | Description |
|---|---|
shell.execute() | Execute a shell script |
shell.open() | Open a persistent shell session |
shell.run() | Run a command in a persistent shell |
shell.close() | Close a persistent shell session |
shell.execute()
Section titled “shell.execute()”Execute a shell script. Accepts either a string (simple command) or a map with options.
Parameters
Section titled “Parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
script | string | — | Shell script to execute |
shell | string | "bash" | Shell to use (bash, sh, zsh) |
workingDir | string | "./" | Working directory |
user | string | — | User to run as |
env | map | — | Environment variables |
inheritenv | bool | true | Inherit parent environment |
interactive | bool | false | Run in interactive mode |
history | bool | false | Enable shell history |
fork | bool | false | Run in separate process group |
templateVars | map | — | Liquid template variables |
stream | bool | true | Stream output to stdout/stderr |
capture | bool | false | Capture output and return it |
Returns
Section titled “Returns”| Field | Type | Description |
|---|---|---|
success | bool | Whether execution succeeded |
error | string | Error message if failed |
output | string | Captured output (when capture: true) |
Examples
Section titled “Examples”// Simple command (string form)shell.execute("echo hello")
// With options (map form)shell.execute({ script: ` npm ci npm run build `, env: { NODE_ENV: "production", CI: "true" }})
// Isolated environmentshell.execute({ script: "env | wc -l", env: { BUILD_MODE: "isolated" }, inheritenv: false})
// Capture outputlet result = shell.execute({ script: "hostname", capture: true})log(result.output)
// Background processshell.execute({ script: "nohup ./daemon.sh &", fork: true})
// Custom working directoryshell.execute({ script: "ls -la", workingDir: "/app/frontend"})shell.open()
Section titled “shell.open()”Open a persistent shell session that can be reused across multiple shell.run() calls. Returns a shell handle.
Parameters
Section titled “Parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
shell | string | "bash" | Shell to use |
workingDir | string | "./" | Working directory |
user | string | — | User to run as |
env | map | — | Environment variables |
inheritenv | bool | true | Inherit parent environment |
fork | bool | false | Run in separate process group |
Returns
Section titled “Returns”| Field | Type | Description |
|---|---|---|
success | bool | Whether the shell was opened |
shellId | string | Shell handle for use with shell.run() and shell.close() |
Examples
Section titled “Examples”// Open a persistent shelllet sh = shell.open({ shell: "bash", workingDir: "/app" })log("Shell opened: " + sh.shellId)shell.run()
Section titled “shell.run()”Execute a command in a persistent shell opened with shell.open().
Parameters
Section titled “Parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
shellId | string | — | Shell handle from shell.open() (required) |
script | string | — | Shell script to execute (required) |
stream | bool | true | Stream output to stdout |
capture | bool | false | Capture output and return it |
templateVars | map | — | Liquid template variables |
Returns
Section titled “Returns”| Field | Type | Description |
|---|---|---|
success | bool | Whether execution succeeded |
error | string | Error message if failed |
output | string | Captured output (when capture: true) |
Examples
Section titled “Examples”// Run commands in a persistent shelllet sh = shell.open({ workingDir: "/app" })
shell.run({ shellId: sh.shellId, script: "npm ci" })shell.run({ shellId: sh.shellId, script: "npm run build" })
// Capture output from persistent shelllet result = shell.run({ shellId: sh.shellId, script: "node --version", capture: true})log("Node version: " + result.output)
shell.close({ shellId: sh.shellId })shell.close()
Section titled “shell.close()”Close a persistent shell session.
Parameters
Section titled “Parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
shellId | string | — | Shell handle from shell.open() (required) |
Returns
Section titled “Returns”| Field | Type | Description |
|---|---|---|
success | bool | Whether the shell was closed |
Examples
Section titled “Examples”// Full persistent shell lifecyclelet sh = shell.open({ shell: "bash" })
shell.run({ shellId: sh.shellId, script: "cd /app && npm ci" })shell.run({ shellId: sh.shellId, script: "npm test" })shell.run({ shellId: sh.shellId, script: "npm run build" })
shell.close({ shellId: sh.shellId })Supershell Namespace
Section titled “Supershell Namespace”Interactive shell session functions with conditional commands, output extraction, and check expressions.
Scope: System
Functions
Section titled “Functions”| Function | Description |
|---|---|
supershell.execute() | Execute an interactive shell session with conditional commands |
supershell.execute()
Section titled “supershell.execute()”Execute multiple commands in a single shell session with support for conditions (test/check), output extraction, and error handling.
Parameters
Section titled “Parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
commands | array | — | List of commands (string or command object) |
shell | string | "bash" | Shell to use |
workingDir | string | "./" | Working directory |
user | string | — | User to run as |
sudo | bool | false | Run with sudo |
onError | string | "terminate" | Error handling: "terminate" or "continue" |
history | bool | false | Enable shell history |
env | map | — | Environment variables |
inheritenv | bool | true | Inherit parent environment |
fork | bool | false | Run in separate process group |
templateVars | map | — | Liquid template variables |
Command Object Properties
Section titled “Command Object Properties”| Property | Type | Description |
|---|---|---|
command | string | Shell command to execute |
test | string | Shell test condition ([ ]) — run only if test succeeds |
testNegated | bool | Negate the test condition |
check | string | JavaScript expression — run only if true |
checkNegated | bool | Negate the check expression |
extract | string/map | Extract output to variable(s). String: full output. Map: regex patterns |
Returns
Section titled “Returns”| Field | Type | Description |
|---|---|---|
success | bool | Whether all commands succeeded |
error | string | Error message if failed |
extractedVars | map | Variables extracted from command output |
commandResults | array | Per-command results with command, output, skipped, skipReason, error |
Examples
Section titled “Examples”// Simple commands (string array)supershell.execute({ commands: [ "echo 'Starting'", "npm install", "npm run build" ]})
// With conditions and extractionsupershell.execute({ commands: [ { command: "git pull", test: "-d .git" }, { command: "npm install", test: "-f package.json" }, { command: "hostname", extract: "server_name" } ]})
// Extract with regex patternssupershell.execute({ commands: [ { command: "cat /etc/os-release | grep VERSION_ID", extract: { os_version: 'VERSION_ID="(.+)"' } }, { command: "free -m | grep Mem", extract: { total_memory: 'Mem:\\s+(\\d+)', used_memory: 'Mem:\\s+\\d+\\s+(\\d+)' } } ]})
// With environment variablessupershell.execute({ commands: [ "echo NODE_ENV=$NODE_ENV", "npm run build" ], env: { NODE_ENV: "production", CI: "true" }})
// Isolated environmentsupershell.execute({ commands: ["env | wc -l"], env: { BUILD_MODE: "isolated" }, inheritenv: false})
// Continue on errorsupershell.execute({ commands: [ "rm -f /tmp/cache/*", "rm -f /tmp/old-logs/*" ], onError: "continue"})
// Result handlinglet result = supershell.execute({ commands: [ { command: "hostname", extract: "host" }, { command: "date", extract: "timestamp" } ]})log(result.extractedVars.host)log(result.extractedVars.timestamp)SSH Namespace
Section titled “SSH Namespace”SSH remote execution functions.
Scope: Network
Functions
Section titled “Functions”| Function | Description |
|---|---|
ssh.connect() | Establish an SSH connection; returns a clientId handle |
ssh.execute() | Execute commands over SSH |
ssh.upload() | Upload a file or directory via SCP |
ssh.download() | Download a file or directory via SCP |
ssh.close() | Close an SSH connection |
ssh.connect() returns a clientId handle that ssh.execute() and
ssh.close() can reuse across calls. ssh.upload() and ssh.download()
always open and close their own connection — pass the connection parameters
directly. ssh.execute() can do either: pass clientId from a previous
ssh.connect(), or pass connection parameters for a one-off connection.
Connection Parameters
Section titled “Connection Parameters”The following parameters describe how to reach the SSH server. Which ones are honoured depends on which function you call.
| Parameter | Type | Default | Description |
|---|---|---|---|
host | string | — | SSH host (host or host:port) |
user | string | — | SSH username |
password | string | — | SSH password |
keyPath | string | — | Path to private key file |
keyPassphrase | string | — | Passphrase for an encrypted private key |
authMethod | string | inferred | "key", "password", or "agent" |
timeout | int | — | Connection timeout in seconds |
strictHostKeyChecking | bool | false | Verify host keys against known_hosts |
knownHostsPath | string | — | Path to a known_hosts file |
agentForwarding | bool | false | Enable SSH agent forwarding |
Which connection parameters each function reads:
| Function | Honours |
|---|---|
ssh.connect() | All of the above |
ssh.execute() (one-off, no clientId) | host, user, password, keyPath |
ssh.upload() | host, user, password, keyPath |
ssh.download() | host, user, password, keyPath |
For richer authentication (passphrases, agent, strict host key checking),
call ssh.connect() first and pass clientId to ssh.execute(). To do the
same on file transfers, use the scp namespace, which supports
the full parameter set directly.
ssh.connect()
Section titled “ssh.connect()”Establish a persistent SSH connection that can be reused across multiple operations.
Returns
Section titled “Returns”| Field | Type | Description |
|---|---|---|
success | bool | Whether the connection succeeded |
clientId | string | Handle for subsequent ssh.execute() / ssh.close() calls |
error | string | Error message when success is false |
Examples
Section titled “Examples”// Connect with key-based authlet conn = ssh.connect({ host: "server.example.com", user: "deploy", keyPath: "~/.ssh/id_rsa"})log("Connected: " + conn.clientId)
// Connect with password and a short timeoutlet conn = ssh.connect({ host: "10.0.0.1:22", user: "admin", password: "secret", timeout: 10})
// Verified host key, agent authlet conn = ssh.connect({ host: "prod.example.com", user: "deploy", authMethod: "agent", strictHostKeyChecking: true, knownHostsPath: "~/.ssh/known_hosts"})ssh.execute()
Section titled “ssh.execute()”Execute commands on a remote server via SSH. Use an existing connection
(clientId) or supply basic connection parameters for a one-off call.
Parameters
Section titled “Parameters”In addition to the connection parameters above:
| Parameter | Type | Default | Description |
|---|---|---|---|
clientId | string | — | Handle from ssh.connect() (alternative to connection params) |
commands | string | — | Shell commands to execute (required) |
env | map | — | Environment variables |
requestPTY | bool | false | Request a pseudo-terminal |
ptyTerminal | string | — | Terminal type for PTY (e.g. "xterm") |
ptyWidth | int | — | PTY width in columns |
ptyHeight | int | — | PTY height in rows |
Returns
Section titled “Returns”| Field | Type | Description |
|---|---|---|
success | bool | Whether execution succeeded |
output | string | Command stdout |
errorOutput | string | Command stderr |
exitCode | int | Process exit code |
error | string | Error message when success is false |
Examples
Section titled “Examples”// Execute on an existing connectionlet conn = ssh.connect({ host: "server.example.com", user: "deploy", keyPath: "~/.ssh/id_rsa"})
let result = ssh.execute({ clientId: conn.clientId, commands: "uptime && df -h"})log("Output: " + result.output)
// One-off execution (no persistent connection)let result = ssh.execute({ host: "server.example.com", user: "deploy", keyPath: "~/.ssh/id_rsa", commands: "hostname"})log("Server: " + result.output)
// With PTY for sudo / interactive commandsssh.execute({ clientId: conn.clientId, commands: "sudo systemctl restart nginx", requestPTY: true, ptyTerminal: "xterm"})
ssh.close({ clientId: conn.clientId })ssh.upload()
Section titled “ssh.upload()”Upload a file or directory to a remote server via SCP. Always opens its own connection.
Parameters
Section titled “Parameters”In addition to the connection parameters above:
| Parameter | Type | Default | Description |
|---|---|---|---|
localPath | string | — | Local file or directory (required) |
remotePath | string | — | Remote destination path (required) |
recursive | bool | false | Upload directories recursively |
preserveMode | bool | false | Preserve file permissions |
Returns
Section titled “Returns”| Field | Type | Description |
|---|---|---|
success | bool | Whether the upload succeeded |
bytesTransferred | int | Number of bytes transferred |
error | string | Error message when success is false |
Examples
Section titled “Examples”// Upload a filelet result = ssh.upload({ host: "server.example.com", user: "deploy", keyPath: "~/.ssh/id_rsa", localPath: "./dist/app.tar.gz", remotePath: "/tmp/app.tar.gz"})log("Uploaded " + result.bytesTransferred + " bytes")
// Upload a directory recursively, preserving permissionsssh.upload({ host: "server.example.com", user: "deploy", keyPath: "~/.ssh/id_rsa", localPath: "./config/", remotePath: "/etc/myapp/", recursive: true, preserveMode: true})ssh.download()
Section titled “ssh.download()”Download a file or directory from a remote server via SCP. Always opens its own connection.
Parameters
Section titled “Parameters”In addition to the connection parameters above:
| Parameter | Type | Default | Description |
|---|---|---|---|
localPath | string | — | Local destination path (required) |
remotePath | string | — | Remote file or directory (required) |
recursive | bool | false | Download directories recursively |
preserveMode | bool | false | Preserve file permissions |
Returns
Section titled “Returns”| Field | Type | Description |
|---|---|---|
success | bool | Whether the download succeeded |
bytesTransferred | int | Number of bytes transferred |
error | string | Error message when success is false |
Examples
Section titled “Examples”// Download a filelet result = ssh.download({ host: "server.example.com", user: "deploy", keyPath: "~/.ssh/id_rsa", remotePath: "/var/log/app.log", localPath: "./logs/app.log"})log("Downloaded " + result.bytesTransferred + " bytes")
// Download a directory recursivelyssh.download({ host: "server.example.com", user: "deploy", keyPath: "~/.ssh/id_rsa", remotePath: "/etc/myapp/", localPath: "./backup/config/", recursive: true})ssh.close()
Section titled “ssh.close()”Close a persistent SSH connection.
Parameters
Section titled “Parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
clientId | string | — | Handle from ssh.connect() (required) |
Returns
Section titled “Returns”| Field | Type | Description |
|---|---|---|
success | bool | Whether the connection was closed |
error | string | Error message when success is false |
Example
Section titled “Example”// Full lifecyclelet conn = ssh.connect({ host: "server.example.com", user: "deploy", keyPath: "~/.ssh/id_rsa"})
ssh.execute({ clientId: conn.clientId, commands: "cd /app && git pull && npm install"})
ssh.execute({ clientId: conn.clientId, commands: "systemctl restart myapp"})
ssh.close({ clientId: conn.clientId })Docker Namespace
Section titled “Docker Namespace”Container operations. Shells out to podman by default; the binary path
is configurable per call. The same eight functions are registered under
two names — see Podman alias below.
The argument shapes work unchanged against the docker CLI — set
binary: "docker" on the call if you need it.
Scope: System
Alias: podman
Section titled “Alias: podman”The podman namespace points at the same eight functions as docker.
Workflows that prefer the literal binary name can call podman.build(...)
— it’s the same function. There is no behaviour difference between the
two namespaces.
Functions
Section titled “Functions”| Function | Description |
|---|---|
docker.build() | Build a container image (also accepts --push to build-and-push in one step) |
docker.push() | Push an image to a registry |
docker.pull() | Pull an image from a registry |
docker.run() | Run a container (detached or foreground) |
docker.login() | Authenticate to a registry; password is sent on stdin |
docker.tag() | Add a new tag to an existing image |
docker.inspect() | Inspect an image / container / network |
docker.rm() | Remove one or more containers |
Common Parameters
Section titled “Common Parameters”Every function accepts these in addition to its own surface:
| Parameter | Type | Default | Description |
|---|---|---|---|
binary | string | "podman" | Container CLI path |
env | map | — | Process environment for the CLI process |
timeout | int or string | — | Wall-clock timeout |
Every function returns at least these fields:
| Field | Type | Description |
|---|---|---|
success | bool | Whether the command exited 0 |
exitCode | int | Process exit code |
output | string | Captured stdout |
stderr | string | Captured stderr |
error | string | Failure message |
docker.build()
Section titled “docker.build()”Parameters
Section titled “Parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
context | string | "." | Build context path |
dockerfile | string | — | Containerfile/Dockerfile path (-f) |
tags | []string | — | Image tags (-t) |
buildArgs | map | — | --build-arg KEY=VALUE |
platforms | []string | — | --platform for multi-arch builds |
target | string | — | --target build stage |
noCache | bool | false | --no-cache |
pull | bool | false | --pull base images on build |
push | bool | false | --push (build and push in one step) |
labels | map | — | --label KEY=VALUE |
secrets | map | — | --secret id=<key>,src=<value> |
Extra return: imageId (parsed from output when recognizable).
let r = docker.build({ context: "./services/api", dockerfile: "build/Dockerfile", tags: ["ghcr.io/example/api:" + sha, "ghcr.io/example/api:latest"], buildArgs: { VERSION: version }, platforms: ["linux/amd64", "linux/arm64"], push: true})if (!r.success) { throw "build failed: " + r.stderr}log("built " + r.imageId)docker.push()
Section titled “docker.push()”| Parameter | Type | Description |
|---|---|---|
image | string | Image:tag (required) |
docker.push({ image: "ghcr.io/example/api:v1.2.3" })docker.pull()
Section titled “docker.pull()”| Parameter | Type | Description |
|---|---|---|
image | string | Image:tag (required) |
platform | string | --platform |
docker.pull({ image: "alpine:3", platform: "linux/arm64" })docker.run()
Section titled “docker.run()”Parameters
Section titled “Parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
image | string | — | Image to run (required) |
name | string | — | --name |
command | string | — | First positional after the image |
args | []string | — | Trailing args |
env | map | — | --env KEY=VALUE (container env) |
mounts | []map | — | --mount entries; each: {source, target, readonly, type} |
ports | []string | — | --publish ("8080:80") |
network | string | — | --network |
workdir | string | — | --workdir |
user | string | — | --user |
entrypoint | string | — | --entrypoint |
labels | map | — | --label |
detach | bool | false | -d |
rm | bool | false | --rm |
interactive | bool | false | -i |
tty | bool | false | -t |
hostEnv | map | — | Env for the podman process itself (rare) |
Mount entries:
| Field | Type | Description |
|---|---|---|
source | string | Host path or volume name |
target | string | Path inside the container |
readonly | bool | ro=true |
type | string | bind (default), volume, or tmpfs |
// One-off migration containerdocker.run({ image: "ghcr.io/example/api:" + sha, rm: true, env: { DATABASE_URL: dbUrl }, command: "./bin/migrate", args: ["--apply"]})
// Long-running detached containerlet r = docker.run({ image: "registry.example.com/worker:latest", name: "worker-1", detach: true, network: "app-net", ports: ["9090:9090"], mounts: [{ source: "/var/log/worker", target: "/var/log/worker" }], env: { WORKER_ID: "1" }})docker.login()
Section titled “docker.login()”| Parameter | Type | Description |
|---|---|---|
registry | string | Hostname (required) |
username | string | Required |
password | string | Required — sent on stdin (--password-stdin), never on the command line |
docker.login({ registry: "ghcr.io", username: vaultGet("ci/ghcr/user"), password: vaultGet("ci/ghcr/token")})docker.tag()
Section titled “docker.tag()”| Parameter | Type | Description |
|---|---|---|
source | string | Existing image (required) |
target | string | New tag (required) |
docker.tag({ source: "ghcr.io/example/api:dev", target: "ghcr.io/example/api:v1.2.3"})docker.inspect()
Section titled “docker.inspect()”| Parameter | Type | Description |
|---|---|---|
target | string | Image / container / network (required) |
type | string | --type filter |
format | string | --format template |
Without format, the raw JSON output is parsed and the first object is
returned under data. With a format, output carries the raw text.
let info = docker.inspect({ target: "worker-1", type: "container" })log("running: " + info.data.State.Running)
// Format-stylelet status = docker.inspect({ target: "worker-1", type: "container", format: "{{.State.Status}}"})log(status.output.trim()) // "running" / "exited" / ...docker.rm()
Section titled “docker.rm()”| Parameter | Type | Description |
|---|---|---|
targets | []string | Container names or IDs (required) |
force | bool | --force |
volumes | bool | --volumes (remove anonymous volumes) |
Extra return: removed ([]string of container IDs that were dropped).
docker.rm({ targets: ["worker-1", "worker-2"], force: true, volumes: true })Podman Namespace
Section titled “Podman Namespace”Alias for the docker namespace. Same eight functions, same
parameters, same return shapes. The underlying binary that gets shelled
out to is podman by default — set binary: "docker" on any call if you
prefer.
There is no behaviour difference between calling podman.build(...) and
docker.build(...). Pick whichever name reads better in your script.
Functions
Section titled “Functions”| Function | Description |
|---|---|
podman.build() | Build a container image |
podman.push() | Push an image to a registry |
podman.pull() | Pull an image from a registry |
podman.run() | Run a container |
podman.login() | Authenticate to a registry (password via stdin) |
podman.tag() | Add a new tag to an image |
podman.inspect() | Inspect an image / container / network |
podman.rm() | Remove one or more containers |
Reference
Section titled “Reference”See docker.md for the full per-function reference. Every
example there works verbatim if you replace docker. with podman..
Quick example
Section titled “Quick example”podman.login({ registry: "ghcr.io", username: vaultGet("ci/ghcr/user"), password: vaultGet("ci/ghcr/token")})
let build = podman.build({ context: "./api", tags: ["ghcr.io/example/api:" + sha], push: true})log("built " + build.imageId)K8s Namespace
Section titled “K8s Namespace”Kubernetes operations via kubectl. The same seven functions are
registered under two names: k8s (short) and kubectl (matches the
binary). Use whichever reads better — they’re the same functions.
Scope: Network
Functions
Section titled “Functions”| Function | Description |
|---|---|
k8s.apply() | Apply a manifest (inline / file / kustomize) |
k8s.delete() | Delete resources by ref / selector / file |
k8s.get() | Read resources (auto-parses JSON into data) |
k8s.exec() | Run a command inside a pod |
k8s.rolloutStatus() | Block until a rollout completes |
k8s.logs() | Fetch container logs |
k8s.scale() | Scale a deployment / statefulset / replicaset |
Common Parameters
Section titled “Common Parameters”Every function accepts:
| Parameter | Type | Default | Description |
|---|---|---|---|
binary | string | "kubectl" | kubectl binary path |
kubeconfig | string | — | --kubeconfig |
context | string | — | --context |
namespace | string | — | --namespace |
env | map | — | Process env for kubectl |
timeout | int or string | — | Wall-clock timeout (also --timeout for rolloutStatus) |
Every function returns:
| Field | Type | Description |
|---|---|---|
success | bool | Whether kubectl exited 0 |
exitCode | int | Exit code |
output | string | Captured stdout |
stderr | string | Captured stderr |
error | string | Failure reason |
k8s.apply()
Section titled “k8s.apply()”| Parameter | Type | Description |
|---|---|---|
manifest | string | Inline YAML/JSON — piped via stdin |
file | string | Path on disk (-f) |
kustomize | string | Path to a kustomize dir (-k) |
serverSide | bool | --server-side |
force | bool | --force |
validate | bool | --validate=... (unset → kubectl default) |
dryRun | string | "client" / "server" / "none" |
fieldManager | string | --field-manager=<name> |
Extra return: applied ([]string of refs).
k8s.apply({ namespace: "app", file: "deploy/app.yaml", serverSide: true})
// Inline manifest, piped to stdink8s.apply({ namespace: "default", manifest: ` apiVersion: v1 kind: ConfigMap metadata: { name: feature-flags } data: { enable_new_dashboard: "true" } `})k8s.delete()
Section titled “k8s.delete()”Provide at least one of: (kind + name), selector, file, or manifest.
| Parameter | Type | Description |
|---|---|---|
kind, name | string, string | Single resource ref |
selector | string | -l <label-selector> |
file | string | -f <path> |
manifest | string | Inline YAML/JSON |
force | bool | --force |
wait | bool | --wait=... (unset → kubectl default) |
gracePeriod | int | --grace-period=<seconds> |
ignoreNotFound | bool | --ignore-not-found=true |
Extra return: deleted ([]string of refs).
k8s.delete({ namespace: "tests", kind: "pod", selector: "owner=integration-tests", ignoreNotFound: true})k8s.get()
Section titled “k8s.get()”| Parameter | Type | Description |
|---|---|---|
kind | string | Required |
name | string | Optional — empty means “list” |
selector | string | -l |
allNamespaces | bool | -A |
format | string | -o (when empty defaults to json and data is parsed) |
showLabels | bool | --show-labels |
Extra return: data — parsed JSON object (single resource) or array
(list). Set only when format is empty.
// Single resourcelet pod = k8s.get({ namespace: "app", kind: "pod", name: "api-0" })log("phase: " + pod.data.status.phase)
// List with selectorlet pods = k8s.get({ namespace: "app", kind: "pod", selector: "app=api" })log("api pods: " + pods.data.items.length)
// Custom format — raw text in `output`, no `data`let names = k8s.get({ namespace: "app", kind: "pod", format: "name" })log(names.output)k8s.exec()
Section titled “k8s.exec()”| Parameter | Type | Description |
|---|---|---|
pod | string | Required |
container | string | -c <container> |
command | string | First positional after -- |
args | []string | Trailing positionals |
stdin | bool | -i |
tty | bool | -t |
let r = k8s.exec({ namespace: "app", pod: "api-7f9b8c4-xyz", container: "api", command: "./bin/migrate", args: ["--apply"]})if (!r.success) { throw "migrate failed: " + r.stderr}k8s.rolloutStatus()
Section titled “k8s.rolloutStatus()”| Parameter | Type | Description |
|---|---|---|
kind | string | deployment (default) / statefulset / daemonset |
name | string | Required |
watch | bool | -w=... (unset → kubectl default) |
The common timeout also becomes --timeout= for kubectl. Recommended
to always set a timeout when calling this function.
k8s.rolloutStatus({ namespace: "app", name: "api", timeout: "5m"})k8s.logs()
Section titled “k8s.logs()”| Parameter | Type | Description |
|---|---|---|
pod | string | Required |
container | string | -c |
since | string | --since= (e.g. "5m", "1h") |
sinceTime | string | --since-time= (RFC3339) |
tail | int | --tail (lines) |
follow | bool | -f — ⚠ blocks until the pod exits |
previous | bool | -p |
timestamps | bool | --timestamps |
allContainers | bool | --all-containers |
let logs = k8s.logs({ namespace: "app", pod: "api-0", container: "api", since: "5m", tail: 200})log(logs.output)k8s.scale()
Section titled “k8s.scale()”| Parameter | Type | Description |
|---|---|---|
kind | string | Required |
name | string | Required |
replicas | int | Target count |
current | int | Optional precondition: --current-replicas=<n> |
k8s.scale({ namespace: "app", kind: "deployment", name: "api", replicas: 5, current: 3 // optional precondition})Kubectl Namespace
Section titled “Kubectl Namespace”Alias for the k8s namespace. Same seven functions, same
parameters, same return shapes. Use whichever name reads better.
There is no behaviour difference between calling kubectl.apply(...) and
k8s.apply(...).
Functions
Section titled “Functions”| Function | Description |
|---|---|
kubectl.apply() | Apply a manifest |
kubectl.delete() | Delete resources |
kubectl.get() | Read resources |
kubectl.exec() | Run a command inside a pod |
kubectl.rolloutStatus() | Block until a rollout completes |
kubectl.logs() | Fetch container logs |
kubectl.scale() | Scale a deployment / statefulset / replicaset |
Reference
Section titled “Reference”See k8s.md for the full per-function reference. Every example
there works verbatim with kubectl. in place of k8s..
Quick example
Section titled “Quick example”kubectl.apply({ namespace: "app", file: "deploy/app.yaml", serverSide: true})
kubectl.rolloutStatus({ namespace: "app", name: "api", timeout: "5m"})