Skip to content

Add tooling to create unit dependency mermaid diagrams displayed by GitLab Markdown

Bogdan-Adrian Burciu requested to merge go-mermaid-diagram into main

What does this MR do and why?

Motivation for this is a personal need to view unit dependencies easier, which became prominent over last MR reviews, plus the positive feedback received in !2044 (comment 1878471251).
Adds:

  • tooling to create mermaid diagrams by unmarshaling output of helm template --show-only templates/units.yaml for different cluster types (bootstrap/management/workload) and flavors (kubeadm-capd/kubeadm-capo/kubeadm-capv/rke2-capd/rke2-capo/rke2-capv/rke2-capm3/rke2-capm3-virt) into Flux Kustomization objects (all other K8s objects - Secret and HelmRepository are discarded), and parsing the Kustomization.spec.dependsOn.
    Feel free to suggest corrections, as this Go code was put together with a lot of trial and error and stiches for Internet suggestions;

  • tiny corrections to environment-values/rke2-capm3/secrets.yaml;

  • enablement of all infra and bootstrap providers in charts/sylva-units/test-values/workload-cluster/shared-settings-mock.values.yaml, which is used for parsing workload cluster templates to pass a mgmt check check:

helm template . --values values.yaml --values workload-cluster.values.yaml --values ../../environment-values/kubeadm-capo/values.yaml --values ../../environment-values/kubeadm-capo/secrets.yaml --values ../../environment-values/workload-clusters/kubeadm-capo/values.yaml --values ../../environment-values/workload-clusters/kubeadm-capo/secrets.yaml --values test-values/workload-cluster/shared-settings-mock.values.yaml -s templates/units.yaml

The Markdown docs pushed here were obtained using:

cd tools/unit-dependency-diagram/ go run  .  --skipUnit root-dependency --allFlavors true

cd /root/sylva/sylva-core/charts/sylva-units/docs/unit-dependency-diagrams/; for mdfile in `ls  *md`; do docker run --rm -u `id -u`:`id -g` -v /root/sylva/sylva-core/charts/sylva-units/docs/unit-dependency-diagrams/:/data minlag/mermaid-cli -i $mdfile -e svg -o $mdfile; done

Adding need some CI job to generate these diagrams can be handled in a follow-up MR, if you agree.

Related reference(s)

Test coverage

Edited by Bogdan-Adrian Burciu

Merge request reports