utility
kubectl
External Kubernetes CLI; select context and namespace explicitly, verify cluster identity, permissions and response structure. Example executes only ./mock/kubectl. No version or cluster verified.
Formal Syntax & Structure
bash syntaxbash
kubectl --context CONTEXT --namespace NAMESPACE get RESOURCE -o jsonReturn Value
exit status
External Kubernetes CLI; select context and namespace explicitly, verify cluster identity, permissions and response structure. Example executes only ./mock/kubectl. No version or cluster verified.
Working Example
Example Snippetbash
mkdir mockcat > mock/kubectl <<'MOCK'#!/bin/bash[[ $# == 8 && $1 == --context && $2 == lab && $3 == --namespace && $4 == demo && $5 == get && $6 == pods && $7 == -o && $8 == json ]] || exit 2printf '{"items":[]}\n'MOCKchmod 700 mock/kubectlargs=(--context lab --namespace demo get pods -o json)json=$(./mock/kubectl "${args[@]}") || exit 1jq -e '.items | type == "array"' <<< "$json"