Interview Prep/Shell Scripting/Scenarios: text processing and scheduling decisions

Find configuration differences between the staging and prod Helm values files.

IntermediateScenarioScenarios: text processing and scheduling decisions
Answer

Situation read → Textual diffs are noisy because of key order and formatting; normalize first.

What I'd do →

diff <(yq -P 'sort_keys(..)' values-staging.yaml) <(yq -P 'sort_keys(..)' values-prod.yaml)

# flat path=value view, easy to read and grep
flat() { yq -o=json '.' "$1" | jq -r 'paths(scalars) as $p | "\($p | map(tostring) | join("."))=\(getpath($p))"' | sort; }
diff <(flat values-staging.yaml) <(flat values-prod.yaml)
  1. sort_keys(..) sorts keys recursively, so order does not matter.
  2. The flattened form shows exactly which path differs (resources.limits.memory=512Mi).

Why → Normalized diffs show real configuration drift between environments.

Interview tip → Mention helm diff upgrade for comparing rendered manifests against what is deployed.

All Shell Scripting questions Roadmap: Shell scripting (Bash)

More on Scenarios: text processing and scheduling decisions