openova/scripts/generate-blueprint-deps.sh
e3mrah 544dc86b5b
fix(wizard): blueprint deps sourced from Flux dependsOn (single source of truth) (#652)
* fix(bp-harbor): grep-oE for password (multi-line tolerant) (chart 1.2.13)

* fix(wizard): blueprint deps from Flux HelmRelease.dependsOn (single source of truth)

The wizard's componentGroups.ts carried hand-maintained `dependencies:
[...]` arrays that deviated from the real Flux install graph in
clusters/_template/bootstrap-kit/*.yaml. Examples (otech34 surfaced
this):

  componentGroups.ts          Flux HelmRelease.dependsOn
  ----------------------      ---------------------------
  keycloak: [cnpg]            keycloak: [cert-manager, gateway-api]
  openbao:  []                openbao:  [spire, gateway-api, cnpg]
  harbor:   [cnpg, seaweedfs, harbor:   [cnpg, cert-manager,
              valkey]                    gateway-api]

Founder's directive: "all the real dependencies are related to real
flux related dependencies, if you are hosting irrelevant hardcoded
baseless wizard catalog dependencies, I dont know where they are
coming from. The single source of truth for the dependencies is
flux!!!" — 2026-05-03

This commit:
  1. Adds scripts/generate-blueprint-deps.sh that parses every
     bootstrap-kit HelmRelease and emits blueprint-deps.generated.json
     keyed by bare component id (bp- prefix stripped on both source
     and target side).
  2. Commits the generated JSON.
  3. Adds products/catalyst/bootstrap/ui/src/data/blueprintDeps.ts
     thin TS wrapper exporting BLUEPRINT_DEPS + depsFor(id).
  4. Patches componentGroups.ts so every RAW_COMPONENT's
     `dependencies` field is OVERRIDDEN at module load with the
     Flux-canonical list (the inline `dependencies: [...]` literals
     are now ignored — Flux is canonical).

Follow-ups (not in this PR):
  - CI drift check that re-runs the script and diffs the JSON.
  - Strip the inline `dependencies: [...]` arrays entirely once the
    drift check is green.
  - Wire the FlowPage edge-rendering to match.

Co-authored-by: hatiyildiz <hatiyildiz@openova.io>

---------

Co-authored-by: hatiyildiz <hatiyildiz@openova.io>
2026-05-03 09:47:52 +04:00

69 lines
2.1 KiB
Bash
Executable File

#!/usr/bin/env bash
# generate-blueprint-deps.sh — emit blueprint-deps.generated.json from
# clusters/_template/bootstrap-kit/*.yaml.
#
# Single source of truth = Flux HelmRelease `dependsOn`. The wizard's
# componentGroups.ts MUST NOT carry hand-maintained dependencies. This
# script parses every bootstrap-kit HelmRelease and emits:
#
# {
# "<component-id>": ["<dep-id>", ...],
# ...
# }
#
# Where `<component-id>` is the bp-<name> with the `bp-` prefix stripped
# (matches componentGroups.ts ids: e.g. `keycloak`, `harbor`, `external-secrets`).
#
# Run pre-build (CI + dev). Output committed at:
# products/catalyst/bootstrap/ui/src/data/blueprint-deps.generated.json
#
# A check job in CI re-runs this and asserts no drift between the
# committed file and the YAML source — blocking PRs that diverge.
set -euo pipefail
REPO_ROOT="$(git -C "$(dirname "$0")/.." rev-parse --show-toplevel)"
KIT_DIR="${REPO_ROOT}/clusters/_template/bootstrap-kit"
OUT_FILE="${REPO_ROOT}/products/catalyst/bootstrap/ui/src/data/blueprint-deps.generated.json"
cd "${KIT_DIR}"
declare -A DEPS
for f in *.yaml; do
[ -f "$f" ] || continue
hr=$(awk 'BEGIN{capture=0} /^kind: HelmRelease/{capture=1} capture && /^ name:/{print $2;exit}' "$f")
[ -z "${hr}" ] && continue
raw_deps=$(awk '/^ dependsOn:/{flag=1;next} flag && /^ [a-z]/{flag=0} flag && /- name:/{print $3}' "$f")
# Strip bp- prefix for both the key and each dep — wizard ids are bare.
key="${hr#bp-}"
list=""
for d in $raw_deps; do
bare="${d#bp-}"
list="${list}${bare}\n"
done
DEPS["${key}"]="${list}"
done
# Emit JSON. Keys sorted for stable diffs.
{
echo "{"
first=1
for k in $(echo "${!DEPS[@]}" | tr ' ' '\n' | sort); do
[ ${first} -eq 0 ] && echo ","
first=0
printf ' "%s": [' "${k}"
inner=""
while IFS= read -r d; do
[ -z "$d" ] && continue
inner="${inner}\"${d}\", "
done <<<"$(echo -e "${DEPS[$k]}")"
inner="${inner%, }"
printf "%s]" "${inner}"
done
echo
echo "}"
} > "${OUT_FILE}.tmp"
mv "${OUT_FILE}.tmp" "${OUT_FILE}"
echo "Wrote ${OUT_FILE}"