From 204f3a49a104a21fc5d55112b3f98cd560900a7a Mon Sep 17 00:00:00 2001 From: Alejandro Mery Date: Sun, 10 Sep 2023 19:53:52 +0000 Subject: [PATCH] drop toml support Signed-off-by: Alejandro Mery --- cmd/jpictl/dump.go | 15 +++------------ go.mod | 1 - go.sum | 2 -- pkg/zones/machine.go | 13 ++++++------- pkg/zones/rings.go | 6 +++--- pkg/zones/zones.go | 13 ++++++------- 6 files changed, 18 insertions(+), 32 deletions(-) diff --git a/cmd/jpictl/dump.go b/cmd/jpictl/dump.go index fb892ba..2d9657a 100644 --- a/cmd/jpictl/dump.go +++ b/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 { diff --git a/go.mod b/go.mod index 31f8fb3..da2402f 100644 --- a/go.mod +++ b/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 diff --git a/go.sum b/go.sum index 0d816c7..3029c5c 100644 --- a/go.sum +++ b/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= diff --git a/pkg/zones/machine.go b/pkg/zones/machine.go index 9c9fc7f..e8f3dbe 100644 --- a/pkg/zones/machine.go +++ b/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 diff --git a/pkg/zones/rings.go b/pkg/zones/rings.go index a2d2176..3a88a8e 100644 --- a/pkg/zones/rings.go +++ b/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 diff --git a/pkg/zones/zones.go b/pkg/zones/zones.go index 155010c..952b305 100644 --- a/pkg/zones/zones.go +++ b/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