Skip to content

CICD-403 · Isolated preview secrets ​

Encyclopedia · Preview environments and developer experience · All snippets

Previous · CICD-402 · Next · CICD-404

1. Where it fits ​

  • Placement CI run step or authorized lab terminal.
  • Prerequisites trusted preview controller, disposable environment and scoped identities for external resources.
  • Platforms kubernetes, local-lab.
  • Parameters PR_NUMBER.

2. Copy the snippet ​

bash
[[ "${PR_NUMBER:?}" =~ ^[0-9]+$ ]]
kubectl -n "preview-$PR_NUMBER" get secret preview-db -o json | jq -e '.metadata.namespace | startswith("preview-")' >/dev/null

3. How it works ​

The expression filters or transforms the input JSON. Where jq -e is used, a false or empty result can fail the gate. The command archives or inspects the selected files. Verify the relative paths and file set before using the archive downstream.

4. Verify the result ​

Provision a per-namespace credential through an external secret controller. Ensure preview app identities lack production access.

Watch for. Use the intended trusted execution context. Keep secret values out of traces, artifacts and debug output.

Validation syntax-validated (Bash parse). Status definitions.