#!/usr/bin/env bash # Reproduces every command and output quoted in the kubeconform post. Output goes to ./recorded/ # Needs network access to raw.githubusercontent.com (schemas are fetched over HTTPS). set -uo pipefail cd "$(dirname "$0")" export PATH="$PWD/../bin:$PATH" rm -rf recorded work; mkdir -p recorded work R="$PWD/recorded" run() { # run : record the command line, the output and the exit code local out="$R/$1"; shift { echo "\$ $*"; "$@"; echo "[exit $?]"; } > "$out" 2>&1 } { kubeconform -v; uname -sm; } > $R/00-version.txt cd manifests run 01-valid.txt kubeconform -summary ok-deployment.yaml run 02-string-replicas.txt kubeconform -summary bad-string-replicas.yaml run 03-missing-selector.txt kubeconform -summary missing-selector.yaml run 04-typo-field-default.txt kubeconform -summary typo-field.yaml run 05-typo-field-strict.txt kubeconform -strict -summary typo-field.yaml run 06-crd-missing-schema.txt kubeconform -summary crd-certificate.yaml run 07-crd-ignore-missing.txt kubeconform -summary -ignore-missing-schemas crd-certificate.yaml run 08-typo-kind.txt kubeconform -summary typo-kind.yaml run 09-typo-kind-ignore-missing.txt kubeconform -summary -ignore-missing-schemas typo-kind.yaml CATALOG='https://raw.githubusercontent.com/datreeio/CRDs-catalog/main/{{.Group}}/{{.ResourceKind}}_{{.ResourceAPIVersion}}.json' run 10-crd-catalog-valid.txt kubeconform -strict -summary -schema-location default -schema-location "$CATALOG" crd-certificate.yaml run 11-crd-catalog-invalid.txt kubeconform -strict -summary -schema-location default -schema-location "$CATALOG" crd-certificate-bad.yaml run 12-removed-api-1.24.txt kubeconform -summary -kubernetes-version 1.24.0 removed-api.yaml run 13-removed-api-1.25.txt kubeconform -summary -kubernetes-version 1.25.0 removed-api.yaml run 14-multi-doc.txt kubeconform -strict -summary multi.yaml run 15-json-output.txt kubeconform -strict -output json multi.yaml # schema cache: the folder must exist first, then a second run needs no network at all rm -rf ../work/cache run 16-cache-folder-missing.txt kubeconform -strict -cache ../work/cache -summary ok-deployment.yaml mkdir -p ../work/cache run 17-cache-cold.txt kubeconform -strict -cache ../work/cache -summary ok-deployment.yaml ls ../work/cache > "$R/18-cache-listing.txt" HTTPS_PROXY=http://127.0.0.1:9 run 19-cache-warm-network-down.txt kubeconform -strict -cache ../work/cache -summary ok-deployment.yaml HTTPS_PROXY=http://127.0.0.1:9 run 20-no-cache-network-down.txt kubeconform -strict -summary ok-deployment.yaml run 25-skip-one-kind.txt kubeconform -summary -skip Certificate crd-certificate.yaml run 26-skip-one-kind-typo-still-fails.txt kubeconform -summary -skip Certificate typo-kind.yaml run 27-selector-mismatch.txt kubeconform -strict -summary selector-mismatch.yaml # the CI workflow shown in the post: linted with actionlint, and the pinned checksum is verified against the real download cd .. { actionlint -version | head -1; } > "$R/21-actionlint-version.txt" run 22-actionlint-workflow.txt actionlint ci/validate-manifests.yml curl -sSfLo work/kc.tgz "https://github.com/yannh/kubeconform/releases/download/v0.8.0/kubeconform-linux-amd64.tar.gz" SHA=$(grep -o 'KUBECONFORM_SHA256: [0-9a-f]*' ci/validate-manifests.yml | cut -d' ' -f2) ( cd work && echo "$SHA kc.tgz" | sha256sum -c - ) > "$R/23-checksum.txt" 2>&1; echo "[exit $?]" >> "$R/23-checksum.txt" # the exact Validate step from the workflow, run locally against a folder of two good manifests mkdir -p work/k8s work/.schema-cache && cp manifests/ok-deployment.yaml manifests/crd-certificate.yaml work/k8s/ ( cd work && run 24-workflow-validate-step.txt kubeconform -strict -summary -kubernetes-version 1.31.0 -cache .schema-cache -schema-location default -schema-location 'https://raw.githubusercontent.com/datreeio/CRDs-catalog/main/{{.Group}}/{{.ResourceKind}}_{{.ResourceAPIVersion}}.json' k8s/ )