From fefbfa16a2654fbe9864b953a892e17f4fd44b6d Mon Sep 17 00:00:00 2001 From: Alejandro Mery Date: Sat, 2 Mar 2024 22:27:13 +0000 Subject: [PATCH] env: export ZONE{zoneID}_REGION Signed-off-by: Alejandro Mery --- pkg/cluster/env.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/pkg/cluster/env.go b/pkg/cluster/env.go index b31f695..f3ee1c6 100644 --- a/pkg/cluster/env.go +++ b/pkg/cluster/env.go @@ -94,6 +94,9 @@ func (m *Env) writeEnvZone(w io.Writer, z *Zone) { gateways, _ := z.GatewayIDs() m.writeEnvVarInts(w, gateways, "ZONE%v_%s", zoneID, "GW") + // ZONE{zoneID}_REGION + m.writeEnvVar(w, genEnvZoneRegion(z), "ZONE%v_%s", zoneID, "REGION") + // Ceph monitors := z.GetCephMonitors() // MON{zoneID}_NAME @@ -166,6 +169,21 @@ func genEnvZoneNodes(z *Zone) string { return "" } +func genEnvZoneRegion(z *Zone) string { + var region string + + z.ForEachRegion(func(r *Region) bool { + if r.Cluster != nil { + region = r.Name + return true + } + + return false + }) + + return region +} + func genEnvZoneCephMonNames(m Machines) string { var buf strings.Builder m.ForEachMachine(func(p *Machine) bool {