From 5abb4c2f9232b5b5f914165fce442e7cca2bfb97 Mon Sep 17 00:00:00 2001 From: Alejandro Mery Date: Sun, 10 Sep 2023 19:01:36 +0000 Subject: [PATCH] cluster: rename pkg/zones to pkg/cluster Signed-off-by: Alejandro Mery --- cmd/jpictl/config.go | 10 +++++----- cmd/jpictl/gateway.go | 19 ++++++++++--------- pkg/{zones => cluster}/ceph.go | 2 +- pkg/{zones => cluster}/ceph_scan.go | 2 +- pkg/cluster/cluster.go | 2 ++ pkg/{zones => cluster}/env.go | 2 +- pkg/{zones => cluster}/errors.go | 2 +- pkg/{zones => cluster}/log.go | 2 +- pkg/{zones => cluster}/machine.go | 2 +- pkg/{zones => cluster}/machine_file.go | 2 +- pkg/{zones => cluster}/machine_rings.go | 2 +- pkg/{zones => cluster}/machine_scan.go | 2 +- pkg/{zones => cluster}/options.go | 2 +- pkg/{zones => cluster}/rings.go | 2 +- pkg/{zones => cluster}/scan.go | 2 +- pkg/{zones => cluster}/sync.go | 2 +- pkg/{zones => cluster}/wireguard.go | 2 +- pkg/{zones => cluster}/zones.go | 3 +-- pkg/{zones => cluster}/zones_file.go | 2 +- 19 files changed, 33 insertions(+), 31 deletions(-) rename pkg/{zones => cluster}/ceph.go (99%) rename pkg/{zones => cluster}/ceph_scan.go (99%) create mode 100644 pkg/cluster/cluster.go rename pkg/{zones => cluster}/env.go (99%) rename pkg/{zones => cluster}/errors.go (96%) rename pkg/{zones => cluster}/log.go (98%) rename pkg/{zones => cluster}/machine.go (98%) rename pkg/{zones => cluster}/machine_file.go (99%) rename pkg/{zones => cluster}/machine_rings.go (99%) rename pkg/{zones => cluster}/machine_scan.go (99%) rename pkg/{zones => cluster}/options.go (99%) rename pkg/{zones => cluster}/rings.go (99%) rename pkg/{zones => cluster}/scan.go (99%) rename pkg/{zones => cluster}/sync.go (97%) rename pkg/{zones => cluster}/wireguard.go (99%) rename pkg/{zones => cluster}/zones.go (98%) rename pkg/{zones => cluster}/zones_file.go (98%) diff --git a/cmd/jpictl/config.go b/cmd/jpictl/config.go index d58439d..df1cd7c 100644 --- a/cmd/jpictl/config.go +++ b/cmd/jpictl/config.go @@ -1,6 +1,6 @@ package main -import "git.jpi.io/amery/jpictl/pkg/zones" +import "git.jpi.io/amery/jpictl/pkg/cluster" // Config describes the repository type Config struct { @@ -14,9 +14,9 @@ var cfg = &Config{ } // LoadZones loads all zones and machines in the config directory -func (cfg *Config) LoadZones(resolve bool) (*zones.Zones, error) { - return zones.New(cfg.Base, cfg.Domain, - zones.ResolvePublicAddresses(resolve), - zones.WithLogger(log), +func (cfg *Config) LoadZones(resolve bool) (*cluster.Zones, error) { + return cluster.New(cfg.Base, cfg.Domain, + cluster.ResolvePublicAddresses(resolve), + cluster.WithLogger(log), ) } diff --git a/cmd/jpictl/gateway.go b/cmd/jpictl/gateway.go index 41b869b..a2489e3 100644 --- a/cmd/jpictl/gateway.go +++ b/cmd/jpictl/gateway.go @@ -7,8 +7,9 @@ import ( "strconv" "strings" - "git.jpi.io/amery/jpictl/pkg/zones" "github.com/spf13/cobra" + + "git.jpi.io/amery/jpictl/pkg/cluster" ) // Command @@ -38,9 +39,9 @@ var gatewaySetCmd = &cobra.Command{ }, } -func gatewaySet(zi zones.ZoneIterator, gw string) error { +func gatewaySet(zi cluster.ZoneIterator, gw string) error { var err error - zi.ForEachZone(func(z *zones.Zone) bool { + zi.ForEachZone(func(z *cluster.Zone) bool { for _, m := range z.Machines { if m.Name == gw { z.SetGateway(m.ID, true) @@ -74,9 +75,9 @@ var gatewayUnsetCmd = &cobra.Command{ }, } -func gatewayUnset(zi zones.ZoneIterator, ngw string) error { +func gatewayUnset(zi cluster.ZoneIterator, ngw string) error { var err error - zi.ForEachZone(func(z *zones.Zone) bool { + zi.ForEachZone(func(z *cluster.Zone) bool { for _, m := range z.Machines { if m.Name == ngw && m.IsGateway() { z.SetGateway(m.ID, false) @@ -115,10 +116,10 @@ var gatewayListCmd = &cobra.Command{ }, } -func gatewayListAll(zi zones.ZoneIterator) error { +func gatewayListAll(zi cluster.ZoneIterator) error { var b bytes.Buffer var err error - zi.ForEachZone(func(z *zones.Zone) bool { + zi.ForEachZone(func(z *cluster.Zone) bool { b.WriteString(z.Name + ":") var sIDs []string ids, num := z.GatewayIDs() @@ -137,10 +138,10 @@ func gatewayListAll(zi zones.ZoneIterator) error { return err } -func gatewayList(zi zones.ZoneIterator, m string) error { +func gatewayList(zi cluster.ZoneIterator, m string) error { var b bytes.Buffer var err error - zi.ForEachZone(func(z *zones.Zone) bool { + zi.ForEachZone(func(z *cluster.Zone) bool { if z.Name == m { b.WriteString(z.Name + ":") ids, num := z.GatewayIDs() diff --git a/pkg/zones/ceph.go b/pkg/cluster/ceph.go similarity index 99% rename from pkg/zones/ceph.go rename to pkg/cluster/ceph.go index 676339b..185dc3d 100644 --- a/pkg/zones/ceph.go +++ b/pkg/cluster/ceph.go @@ -1,4 +1,4 @@ -package zones +package cluster import ( "bytes" diff --git a/pkg/zones/ceph_scan.go b/pkg/cluster/ceph_scan.go similarity index 99% rename from pkg/zones/ceph_scan.go rename to pkg/cluster/ceph_scan.go index 7cb4f37..a64e2d7 100644 --- a/pkg/zones/ceph_scan.go +++ b/pkg/cluster/ceph_scan.go @@ -1,4 +1,4 @@ -package zones +package cluster import ( "os" diff --git a/pkg/cluster/cluster.go b/pkg/cluster/cluster.go new file mode 100644 index 0000000..bd55f18 --- /dev/null +++ b/pkg/cluster/cluster.go @@ -0,0 +1,2 @@ +// Package cluster contains information about the cluster +package cluster diff --git a/pkg/zones/env.go b/pkg/cluster/env.go similarity index 99% rename from pkg/zones/env.go rename to pkg/cluster/env.go index 8780da9..86439e4 100644 --- a/pkg/zones/env.go +++ b/pkg/cluster/env.go @@ -1,4 +1,4 @@ -package zones +package cluster import ( "bytes" diff --git a/pkg/zones/errors.go b/pkg/cluster/errors.go similarity index 96% rename from pkg/zones/errors.go rename to pkg/cluster/errors.go index 6fd068f..9035d36 100644 --- a/pkg/zones/errors.go +++ b/pkg/cluster/errors.go @@ -1,4 +1,4 @@ -package zones +package cluster import "errors" diff --git a/pkg/zones/log.go b/pkg/cluster/log.go similarity index 98% rename from pkg/zones/log.go rename to pkg/cluster/log.go index ceaf5ee..d386041 100644 --- a/pkg/zones/log.go +++ b/pkg/cluster/log.go @@ -1,4 +1,4 @@ -package zones +package cluster import "darvaza.org/slog" diff --git a/pkg/zones/machine.go b/pkg/cluster/machine.go similarity index 98% rename from pkg/zones/machine.go rename to pkg/cluster/machine.go index e8f3dbe..d8c38f1 100644 --- a/pkg/zones/machine.go +++ b/pkg/cluster/machine.go @@ -1,4 +1,4 @@ -package zones +package cluster import ( "net/netip" diff --git a/pkg/zones/machine_file.go b/pkg/cluster/machine_file.go similarity index 99% rename from pkg/zones/machine_file.go rename to pkg/cluster/machine_file.go index 6fd0eac..a6e90eb 100644 --- a/pkg/zones/machine_file.go +++ b/pkg/cluster/machine_file.go @@ -1,4 +1,4 @@ -package zones +package cluster import ( "bytes" diff --git a/pkg/zones/machine_rings.go b/pkg/cluster/machine_rings.go similarity index 99% rename from pkg/zones/machine_rings.go rename to pkg/cluster/machine_rings.go index 4baaaee..cffcd4f 100644 --- a/pkg/zones/machine_rings.go +++ b/pkg/cluster/machine_rings.go @@ -1,4 +1,4 @@ -package zones +package cluster import ( "bytes" diff --git a/pkg/zones/machine_scan.go b/pkg/cluster/machine_scan.go similarity index 99% rename from pkg/zones/machine_scan.go rename to pkg/cluster/machine_scan.go index cb5a1be..e282800 100644 --- a/pkg/zones/machine_scan.go +++ b/pkg/cluster/machine_scan.go @@ -1,4 +1,4 @@ -package zones +package cluster import ( "context" diff --git a/pkg/zones/options.go b/pkg/cluster/options.go similarity index 99% rename from pkg/zones/options.go rename to pkg/cluster/options.go index e7a66f2..b4f0ac2 100644 --- a/pkg/zones/options.go +++ b/pkg/cluster/options.go @@ -1,4 +1,4 @@ -package zones +package cluster import ( "io/fs" diff --git a/pkg/zones/rings.go b/pkg/cluster/rings.go similarity index 99% rename from pkg/zones/rings.go rename to pkg/cluster/rings.go index 3a88a8e..64cae1c 100644 --- a/pkg/zones/rings.go +++ b/pkg/cluster/rings.go @@ -1,4 +1,4 @@ -package zones +package cluster import ( "fmt" diff --git a/pkg/zones/scan.go b/pkg/cluster/scan.go similarity index 99% rename from pkg/zones/scan.go rename to pkg/cluster/scan.go index c7b4eef..090ba89 100644 --- a/pkg/zones/scan.go +++ b/pkg/cluster/scan.go @@ -1,4 +1,4 @@ -package zones +package cluster import ( "io/fs" diff --git a/pkg/zones/sync.go b/pkg/cluster/sync.go similarity index 97% rename from pkg/zones/sync.go rename to pkg/cluster/sync.go index b7c8b89..f8eb344 100644 --- a/pkg/zones/sync.go +++ b/pkg/cluster/sync.go @@ -1,4 +1,4 @@ -package zones +package cluster // SyncAll updates all config files func (m *Zones) SyncAll() error { diff --git a/pkg/zones/wireguard.go b/pkg/cluster/wireguard.go similarity index 99% rename from pkg/zones/wireguard.go rename to pkg/cluster/wireguard.go index 35888db..7bf94af 100644 --- a/pkg/zones/wireguard.go +++ b/pkg/cluster/wireguard.go @@ -1,4 +1,4 @@ -package zones +package cluster import ( "io/fs" diff --git a/pkg/zones/zones.go b/pkg/cluster/zones.go similarity index 98% rename from pkg/zones/zones.go rename to pkg/cluster/zones.go index 952b305..26d9bb8 100644 --- a/pkg/zones/zones.go +++ b/pkg/cluster/zones.go @@ -1,5 +1,4 @@ -// Package zones contains information about the cluster -package zones +package cluster import ( "io/fs" diff --git a/pkg/zones/zones_file.go b/pkg/cluster/zones_file.go similarity index 98% rename from pkg/zones/zones_file.go rename to pkg/cluster/zones_file.go index b711163..b5adce5 100644 --- a/pkg/zones/zones_file.go +++ b/pkg/cluster/zones_file.go @@ -1,4 +1,4 @@ -package zones +package cluster import ( "fmt"