Browse Source

drop toml support

Signed-off-by: Alejandro Mery <amery@jpi.io>
pull/16/head
Alejandro Mery 10 months ago
parent
commit
204f3a49a1
  1. 15
      cmd/jpictl/dump.go
  2. 1
      go.mod
  3. 2
      go.sum
  4. 13
      pkg/zones/machine.go
  5. 6
      pkg/zones/rings.go
  6. 13
      pkg/zones/zones.go

15
cmd/jpictl/dump.go

@ -6,7 +6,6 @@ import (
"io"
"os"
"github.com/burntSushi/toml"
"github.com/spf13/cobra"
"gopkg.in/yaml.v3"
)
@ -20,8 +19,8 @@ type Encoder interface {
type Encoding int
const (
// TOMLEncoding represents TOML encoding
TOMLEncoding Encoding = iota
// UndefinedEncoding implies the default encoding
UndefinedEncoding Encoding = iota
// JSONEncoding represents JSON encoding
JSONEncoding
// YAMLEncoding represents YAML encoding
@ -42,12 +41,6 @@ func NewYAMLEncoder(w io.Writer) Encoder {
return enc
}
// NewTOMLEncoder returns a TOML [Encoder] to work on the given [io.Writer]
func NewTOMLEncoder(w io.Writer) Encoder {
enc := toml.NewEncoder(w)
return enc
}
const encoding = YAMLEncoding
// Command
@ -66,10 +59,8 @@ var dumpCmd = &cobra.Command{
switch encoding {
case JSONEncoding:
enc = NewJSONEncoder(&buf)
case YAMLEncoding:
enc = NewYAMLEncoder(&buf)
default:
enc = NewTOMLEncoder(&buf)
enc = NewYAMLEncoder(&buf)
}
if err = enc.Encode(m); err != nil {

1
go.mod

@ -9,7 +9,6 @@ require (
darvaza.org/sidecar v0.0.2
darvaza.org/slog v0.5.3
darvaza.org/slog/handlers/discard v0.4.5
github.com/burntSushi/toml v0.3.1
github.com/gofrs/uuid/v5 v5.0.0
github.com/hack-pad/hackpadfs v0.2.1
github.com/mgechev/revive v1.3.3

2
go.sum

@ -18,8 +18,6 @@ darvaza.org/slog/handlers/zerolog v0.4.5 h1:W4cgGORx4wImr+RL96CWSQGTdkZzKX6YHXPS
darvaza.org/slog/handlers/zerolog v0.4.5/go.mod h1:mCoh/mIl8Nsa6Yu1Um7d7cos6RuEJzgaTXaX5LDRUao=
github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8=
github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
github.com/burntSushi/toml v0.3.1 h1:Hu1cOEC2qtKULZJCzym5tyA35bZr3HREuolgiAzMlhY=
github.com/burntSushi/toml v0.3.1/go.mod h1:sGTquCpRYr9McuHdv0m6YKIhx8DJGJa4t04/Y9pfSio=
github.com/chavacava/garif v0.1.0 h1:2JHa3hbYf5D9dsgseMKAmc/MZ109otzgNFk5s87H9Pc=
github.com/chavacava/garif v0.1.0/go.mod h1:XMyYCkEL58DF0oyW4qDjjnPWONs2HBqYKI+UIPD+Gww=
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=

13
pkg/zones/machine.go

@ -10,15 +10,14 @@ import (
// A Machine is a machine on a Zone
type Machine struct {
zone *Zone
logger `toml:"-" json:"-" yaml:"-"`
logger `json:"-" yaml:"-"`
ID int `toml:"id"`
Name string `toml:"-" json:"-" yaml:"-"`
ID int
Name string `json:"-" yaml:"-"`
PublicAddresses []netip.Addr `toml:"public,omitempty" json:"public,omitempty" yaml:"public,omitempty"`
Rings []*RingInfo `toml:"rings,omitempty" json:"rings,omitempty" yaml:"rings,omitempty"`
CephMonitor bool `toml:"ceph_monitor,omitempty" json:"ceph_monitor,omitempty" yaml:"ceph_monitor,omitempty"`
CephMonitor bool `json:"ceph_monitor,omitempty" yaml:"ceph_monitor,omitempty"`
PublicAddresses []netip.Addr `json:"public,omitempty" yaml:"public,omitempty"`
Rings []*RingInfo `json:"rings,omitempty" yaml:"rings,omitempty"`
}
// revive:enable:line-length-limit

6
pkg/zones/rings.go

@ -24,9 +24,9 @@ const (
// RingInfo contains represents the Wireguard endpoint details
// for a Machine on a particular ring
type RingInfo struct {
Ring int `toml:"ring"`
Enabled bool `toml:"enabled,omitempty"`
Keys wireguard.KeyPair `toml:"keys,omitempty"`
Ring int
Enabled bool
Keys wireguard.KeyPair
}
// Merge attempts to combine two RingInfo structs

13
pkg/zones/zones.go

@ -88,12 +88,12 @@ func FilterMachines(m MachineIterator, cond func(*Machine) bool) (Machines, int)
// Zone represents one zone in a cluster
type Zone struct {
zones *Zones
logger `toml:"-" json:"-" yaml:"-"`
logger `json:"-" yaml:"-"`
ID int `toml:"id"`
Name string `toml:"name"`
ID int
Name string
Machines `toml:"machines"`
Machines
}
func (z *Zone) String() string {
@ -147,9 +147,8 @@ type Zones struct {
resolver resolver.Resolver
domain string
CephFSID uuid.UUID `toml:"ceph_fsid,omitempty" json:"ceph_fsid,omitempty" yaml:"ceph_fsid,omitempty"`
Zones []*Zone `toml:"zones"`
CephFSID uuid.UUID `json:"ceph_fsid,omitempty" yaml:"ceph_fsid,omitempty"`
Zones []*Zone
}
// revive:enable:line-length-limit

Loading…
Cancel
Save