cluster: introduce NodeID and ZoneID types

Signed-off-by: Alejandro Mery <amery@jpi.io>
This commit is contained in:
2024-05-28 19:40:18 +00:00
parent e1186975a6
commit 6c875ae832
11 changed files with 72 additions and 57 deletions
+4 -4
View File
@@ -19,7 +19,7 @@ type Zone struct {
zones *Cluster
logger `json:"-" yaml:"-"`
ID int
ID ZoneID
Name string
Regions []string `json:",omitempty" yaml:",omitempty"`
@@ -31,7 +31,7 @@ func (z *Zone) String() string {
}
// SetGateway configures a machine to be the zone's ring0 gateway
func (z *Zone) SetGateway(gatewayID int, enabled bool) error {
func (z *Zone) SetGateway(gatewayID NodeID, enabled bool) error {
var err error
var found bool
@@ -56,8 +56,8 @@ func (z *Zone) SetGateway(gatewayID int, enabled bool) error {
}
// GatewayIDs returns the list of IDs of machines that act as ring0 gateways
func (z *Zone) GatewayIDs() ([]int, int) {
var out []int
func (z *Zone) GatewayIDs() ([]NodeID, int) {
var out []NodeID
z.ForEachMachine(func(p *Machine) bool {
if p.IsGateway() {
out = append(out, p.ID)