Browse Source

cluster: rename pkg/zones to pkg/cluster

Signed-off-by: Alejandro Mery <amery@jpi.io>
pull/18/head
Alejandro Mery 1 year ago
parent
commit
5abb4c2f92
  1. 10
      cmd/jpictl/config.go
  2. 19
      cmd/jpictl/gateway.go
  3. 2
      pkg/cluster/ceph.go
  4. 2
      pkg/cluster/ceph_scan.go
  5. 2
      pkg/cluster/cluster.go
  6. 2
      pkg/cluster/env.go
  7. 2
      pkg/cluster/errors.go
  8. 2
      pkg/cluster/log.go
  9. 2
      pkg/cluster/machine.go
  10. 2
      pkg/cluster/machine_file.go
  11. 2
      pkg/cluster/machine_rings.go
  12. 2
      pkg/cluster/machine_scan.go
  13. 2
      pkg/cluster/options.go
  14. 2
      pkg/cluster/rings.go
  15. 2
      pkg/cluster/scan.go
  16. 2
      pkg/cluster/sync.go
  17. 2
      pkg/cluster/wireguard.go
  18. 3
      pkg/cluster/zones.go
  19. 2
      pkg/cluster/zones_file.go

10
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),
)
}

19
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()

2
pkg/zones/ceph.go → pkg/cluster/ceph.go

@ -1,4 +1,4 @@
package zones
package cluster
import (
"bytes"

2
pkg/zones/ceph_scan.go → pkg/cluster/ceph_scan.go

@ -1,4 +1,4 @@
package zones
package cluster
import (
"os"

2
pkg/cluster/cluster.go

@ -0,0 +1,2 @@
// Package cluster contains information about the cluster
package cluster

2
pkg/zones/env.go → pkg/cluster/env.go

@ -1,4 +1,4 @@
package zones
package cluster
import (
"bytes"

2
pkg/zones/errors.go → pkg/cluster/errors.go

@ -1,4 +1,4 @@
package zones
package cluster
import "errors"

2
pkg/zones/log.go → pkg/cluster/log.go

@ -1,4 +1,4 @@
package zones
package cluster
import "darvaza.org/slog"

2
pkg/zones/machine.go → pkg/cluster/machine.go

@ -1,4 +1,4 @@
package zones
package cluster
import (
"net/netip"

2
pkg/zones/machine_file.go → pkg/cluster/machine_file.go

@ -1,4 +1,4 @@
package zones
package cluster
import (
"bytes"

2
pkg/zones/machine_rings.go → pkg/cluster/machine_rings.go

@ -1,4 +1,4 @@
package zones
package cluster
import (
"bytes"

2
pkg/zones/machine_scan.go → pkg/cluster/machine_scan.go

@ -1,4 +1,4 @@
package zones
package cluster
import (
"context"

2
pkg/zones/options.go → pkg/cluster/options.go

@ -1,4 +1,4 @@
package zones
package cluster
import (
"io/fs"

2
pkg/zones/rings.go → pkg/cluster/rings.go

@ -1,4 +1,4 @@
package zones
package cluster
import (
"fmt"

2
pkg/zones/scan.go → pkg/cluster/scan.go

@ -1,4 +1,4 @@
package zones
package cluster
import (
"io/fs"

2
pkg/zones/sync.go → pkg/cluster/sync.go

@ -1,4 +1,4 @@
package zones
package cluster
// SyncAll updates all config files
func (m *Zones) SyncAll() error {

2
pkg/zones/wireguard.go → pkg/cluster/wireguard.go

@ -1,4 +1,4 @@
package zones
package cluster
import (
"io/fs"

3
pkg/zones/zones.go → pkg/cluster/zones.go

@ -1,5 +1,4 @@
// Package zones contains information about the cluster
package zones
package cluster
import (
"io/fs"

2
pkg/zones/zones_file.go → pkg/cluster/zones_file.go

@ -1,4 +1,4 @@
package zones
package cluster
import (
"fmt"
Loading…
Cancel
Save