From b7cd6f497b630fcceef3bc6f31ad3123036f2761 Mon Sep 17 00:00:00 2001 From: Simon Gerber Date: Wed, 8 Jan 2025 11:13:23 +0100 Subject: [PATCH] Extend `allInstances` with the component names for instantiated components The design doc (SDD-0030) specifies that entries in `syn..instances` must be component instances. However, Commodore doesn't require that instance-aware components generate an ArgoCD application per instance, and some existing components generate a single ArgoCD application for all their instances. For such components, individual instances can't be assigned to a team, but the whole component can be assigned. To accommodate this design choice, we keep both the instance and component names in `allInstances` for instantiated components. This ensures that library consumers can correctly look up the team for a component which generates a single ArgoCD application for all instances. --- syn-teams.libsonnet | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/syn-teams.libsonnet b/syn-teams.libsonnet index 2504df8..6d6905e 100644 --- a/syn-teams.libsonnet +++ b/syn-teams.libsonnet @@ -60,10 +60,15 @@ local appKeys(name, raw=false) = // Extract all instances from `inv.applications`. // The design doc (SDD-0030) specifies that entries in `syn..instances` -// must be component instances, so we don't need to worry about the component -// name for instantiated components. +// must be component instances. +// However, Commodore doesn't require that instance-aware components generate +// an ArgoCD application per instance, and some existing components generate a +// single ArgoCD application for all their instances. For such components, +// individual instances can't be assigned to a team, but the whole component +// can be assigned. To accommodate this design choice, we keep both the +// instance and component name in allInstances for instantiated components. local allInstances = std.set( - std.map(function(app) appKeys(app, true)[0], inv.applications) + std.flattenArrays(std.map(function(app) appKeys(app, true), inv.applications)) );