From c81b782b261ddce8360c40d79cb1ff127e7ca418 Mon Sep 17 00:00:00 2001 From: Alejandro Mery Date: Wed, 23 Aug 2023 20:04:47 +0000 Subject: [PATCH] zones: Machine.IsGateway() Signed-off-by: Alejandro Mery --- pkg/zones/env.go | 2 +- pkg/zones/machine.go | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/pkg/zones/env.go b/pkg/zones/env.go index 35a1ff1..a28496e 100644 --- a/pkg/zones/env.go +++ b/pkg/zones/env.go @@ -86,7 +86,7 @@ func getRingZeroGatewayID(z *Zone) int { firstNodeID = p.ID } - if _, ok := p.getRingInfo(0); ok { + if p.IsGateway() { gatewayID = p.ID } diff --git a/pkg/zones/machine.go b/pkg/zones/machine.go index 6b7effc..8d04a0e 100644 --- a/pkg/zones/machine.go +++ b/pkg/zones/machine.go @@ -58,6 +58,12 @@ func (m *Machine) getFilename(name string, args ...any) string { return filepath.Join(s...) } +// IsGateway tells if the Machine is a ring0 gateway +func (m *Machine) IsGateway() bool { + _, ok := m.getRingInfo(0) + return ok +} + func (m *Machine) getPeerByName(name string) (*Machine, bool) { return m.zone.zones.GetMachineByName(name) }