Browse Source

zones: Env: allow multiple gateways on a Zone

Signed-off-by: Alejandro Mery <amery@jpi.io>
pull/4/head
Alejandro Mery 1 year ago
parent
commit
71a1d1a7c2
  1. 20
      pkg/zones/env.go

20
pkg/zones/env.go

@ -57,10 +57,8 @@ func (m *Env) writeEnvZone(w io.Writer, z *Zone) {
m.writeEnvVar(w, z.Name, "ZONE%v_%s", zoneID, "NAME")
// ZONE{zoneID}_GW
gatewayID := getRingZeroGatewayID(z)
if gatewayID > 0 {
m.writeEnvVar(w, fmt.Sprintf("%v", gatewayID), "ZONE%v_%s", zoneID, "GW")
}
gateways, _ := z.GatewayIDs()
m.writeEnvVarInts(w, gateways, "ZONE%v_%s", zoneID, "GW")
}
func (m *Env) writeEnvVarInts(w io.Writer, value []int, name string, args ...any) {
@ -113,17 +111,3 @@ func genEnvZoneNodes(z *Zone) string {
}
return ""
}
func getRingZeroGatewayID(z *Zone) int {
var gatewayID int
z.ForEachMachine(func(p *Machine) bool {
if p.IsGateway() {
gatewayID = p.ID
}
return gatewayID != 0
})
return gatewayID
}

Loading…
Cancel
Save