feat(gitops-update): support per-cluster env suffix variants (-st / -mt)#423
feat(gitops-update): support per-cluster env suffix variants (-st / -mt)#423ferr3ira-gabriel wants to merge 1 commit into
Conversation
Adds two additive, backward-compatible fields to the deployment matrix
manifest to express clusters that host multiple parallel variants per
environment (e.g. single-tenant -st + multi-tenant -mt on benedita):
clusters:
benedita:
env_suffixes: ["-st", "-mt"]
suffix_excludes_envs: ["sandbox"]
The gitops-update workflow expands each tag-derived env (dev/stg/prd/sandbox)
against the cluster's env_suffixes, except envs listed in suffix_excludes_envs
which stay bare. The expanded env name flows through unchanged to the helmfile
path resolution and the ArgoCD app name template, so 'benedita-midaz-dev-st'
resolves naturally without any new workflow inputs.
Cross apps (those with app_helmfile_env set, e.g. forge: cross) bypass the
suffix expansion - they update once at the override path and their sync target
uses the override env, so 'benedita-forge-cross' resolves correctly when the
cluster renames its ArgoCD apps to follow the {server}-{app}-{env} convention.
Defaults preserve byte-identical behavior for firmino/clotilde/anacleto:
env_suffixes defaults to [""] (single empty-suffix expansion), suffix_excludes_envs
defaults to []. Tag-derived env list for those clusters is unchanged.
Also extends the deployment-matrix lint action to validate the new fields
plus the pre-existing app_helmfile_env field (which was previously unvalidated).
Closes #422
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (4)
WalkthroughThe PR extends the GitOps deployment matrix workflow to support per-cluster environment suffix variants, enabling clusters like Benedita to run multiple parallel environments (single-tenant, multi-tenant) per base environment. It adds schema fields, validation, environment expansion logic, corrects ArgoCD sync targets, and deduplicates output. ChangesPer-Cluster Environment Suffix Variants
🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
🛡️ CodeQL Analysis ResultsLanguages analyzed: Found 2 issue(s): 2 Medium
🔍 View full scan logs | 🛡️ Security tab |
🔍 PR Validation Summary✅ PR Mergeable — no blocking failures
|
🔍 Lint Analysis
|
Summary
Adds per-cluster env-suffix expansion to the
gitops-updateworkflow so clusters that host multiple parallel variants per environment (e.g. Benedita with single-tenant-stand multi-tenant-mt) can be onboarded without forking the workflow.Closes #422.
Manifest change (additive)
Both fields are optional:
env_suffixes[""]suffix_excludes_envs[]Resolution example
Manifest: benedita declares
env_suffixes: ["-st", "-mt"],suffix_excludes_envs: ["sandbox"].v1.2.3-beta.1)devdev-st,dev-mtv1.2.3-rc.1)stgstg-st,stg-mtv1.2.3)dev stg prd sandboxdev-st,dev-mt,stg-st,stg-mt,prd-st,prd-mt,sandboxv1.2.3-sandbox.1)sandboxsandboxFor firmino/clotilde/anacleto (no manifest change),
env_suffixesdefaults to[""], so the final env list equals the tag-derived list verbatim. Byte-identical behavior to today.Workflow changes
resolve_clustersstep — extended to emit a per-cluster JSON map ofenv_suffixesandsuffix_excludes_envsresolved from the manifest (with defaults applied).apply_tagsstep — new helperexpand_envs_for_serverruns the cross-product of the tag-derived env list × the cluster'senv_suffixes, withsuffix_excludes_envshonored. The expanded env name flows through unchanged to:environments/{server}/helmfile/applications/{ENV}/{app}/values.yamlwhereENVis nowdev-stetc.{server}-{app}-{env}by default) —benedita-midaz-dev-stresolves naturally with no new workflow inputs.Cross-app handling — when an app has
app_helmfile_envset (e.g.forge: cross), the suffix expansion is bypassed and the sync target's env equals the override value (cross). This makesbenedita-forge-crossthe correct ArgoCD app name once the cross apps are renamed to follow the standard convention.Sync-matrix dedup — the updated
(server, env)pairs are now de-duplicated before being emitted as the ArgoCD sync matrix. This prevents cross apps (visited once per outer env iteration) from being queued for sync multiple times.Kustomize layout — unchanged. The kustomize branch already bypasses the env list when its sentinel env (
-) is in effect;expand_envs_for_serverreturns the input unchanged in that case.Lint extension
src/lint/deployment-matrix/action.ymlwas previously validating onlyversion,apps.registry, andclusters.<name>.apps. This PR extends it to validate:env_suffixes(list of strings, unique, non-empty list)suffix_excludes_envs(list of valid env names; warns if pointing at unknown env or used withoutenv_suffixes)app_helmfile_env(pre-existing field, now validated: dict whose keys must reference apps in the cluster'sappslist)Testing
Simulated the full env resolution offline against the updated manifest for all four clusters × four tag types. Output verified manually:
Workflow and action YAML pass
actionlintclean.Extended lint passes on the updated manifest (
violations=0 warnings=0).Out of scope
app_env_suffixesin a follow-up when an actual MT-only or ST-only app emerges.benedita-forge→benedita-forge-cross, etc.) — handled separately in the gitops repo by the cluster owner.Reviewer checklist
config/deployment-matrix.ymlreads sensibly and the schema comments make the new fields discoverablegitops-update.ymlpreserves existing behavior for firmino/clotilde/anacleto (defaultenv_suffixes=[""]produces no env list change)expand_envs_for_servercorrectly handles edge cases: emptyENV_CONFIG, kustomize sentinel-, missing fieldssort -uand the resulting JSON array preserves the (server, env) shapedocs/gitops-update-workflow.mddescribes the new fields and resolution rulessrc/lint/deployment-matrix/action.ymlcovers the new fields and the pre-existingapp_helmfile_envSummary by CodeRabbit
New Features
Documentation
Chores