drop toml support #16
+3
-12
@@ -6,7 +6,6 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/burntSushi/toml"
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
)
|
)
|
||||||
@@ -20,8 +19,8 @@ type Encoder interface {
|
|||||||
type Encoding int
|
type Encoding int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// TOMLEncoding represents TOML encoding
|
// UndefinedEncoding implies the default encoding
|
||||||
TOMLEncoding Encoding = iota
|
UndefinedEncoding Encoding = iota
|
||||||
// JSONEncoding represents JSON encoding
|
// JSONEncoding represents JSON encoding
|
||||||
JSONEncoding
|
JSONEncoding
|
||||||
// YAMLEncoding represents YAML encoding
|
// YAMLEncoding represents YAML encoding
|
||||||
@@ -42,12 +41,6 @@ func NewYAMLEncoder(w io.Writer) Encoder {
|
|||||||
return enc
|
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
|
const encoding = YAMLEncoding
|
||||||
|
|
||||||
// Command
|
// Command
|
||||||
@@ -66,10 +59,8 @@ var dumpCmd = &cobra.Command{
|
|||||||
switch encoding {
|
switch encoding {
|
||||||
case JSONEncoding:
|
case JSONEncoding:
|
||||||
enc = NewJSONEncoder(&buf)
|
enc = NewJSONEncoder(&buf)
|
||||||
case YAMLEncoding:
|
|
||||||
enc = NewYAMLEncoder(&buf)
|
|
||||||
default:
|
default:
|
||||||
enc = NewTOMLEncoder(&buf)
|
enc = NewYAMLEncoder(&buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = enc.Encode(m); err != nil {
|
if err = enc.Encode(m); err != nil {
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ require (
|
|||||||
darvaza.org/sidecar v0.0.2
|
darvaza.org/sidecar v0.0.2
|
||||||
darvaza.org/slog v0.5.3
|
darvaza.org/slog v0.5.3
|
||||||
darvaza.org/slog/handlers/discard v0.4.5
|
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/gofrs/uuid/v5 v5.0.0
|
||||||
github.com/hack-pad/hackpadfs v0.2.1
|
github.com/hack-pad/hackpadfs v0.2.1
|
||||||
github.com/mgechev/revive v1.3.3
|
github.com/mgechev/revive v1.3.3
|
||||||
|
|||||||
@@ -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=
|
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 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8=
|
||||||
github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
|
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 h1:2JHa3hbYf5D9dsgseMKAmc/MZ109otzgNFk5s87H9Pc=
|
||||||
github.com/chavacava/garif v0.1.0/go.mod h1:XMyYCkEL58DF0oyW4qDjjnPWONs2HBqYKI+UIPD+Gww=
|
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=
|
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
|
||||||
|
|||||||
@@ -10,15 +10,14 @@ import (
|
|||||||
// A Machine is a machine on a Zone
|
// A Machine is a machine on a Zone
|
||||||
type Machine struct {
|
type Machine struct {
|
||||||
zone *Zone
|
zone *Zone
|
||||||
logger `toml:"-" json:"-" yaml:"-"`
|
logger `json:"-" yaml:"-"`
|
||||||
|
|
||||||
ID int `toml:"id"`
|
ID int
|
||||||
Name string `toml:"-" json:"-" yaml:"-"`
|
Name string `json:"-" yaml:"-"`
|
||||||
|
|
||||||
PublicAddresses []netip.Addr `toml:"public,omitempty" json:"public,omitempty" yaml:"public,omitempty"`
|
CephMonitor bool `json:"ceph_monitor,omitempty" yaml:"ceph_monitor,omitempty"`
|
||||||
Rings []*RingInfo `toml:"rings,omitempty" json:"rings,omitempty" yaml:"rings,omitempty"`
|
PublicAddresses []netip.Addr `json:"public,omitempty" yaml:"public,omitempty"`
|
||||||
|
Rings []*RingInfo `json:"rings,omitempty" yaml:"rings,omitempty"`
|
||||||
CephMonitor bool `toml:"ceph_monitor,omitempty" json:"ceph_monitor,omitempty" yaml:"ceph_monitor,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// revive:enable:line-length-limit
|
// revive:enable:line-length-limit
|
||||||
|
|||||||
+3
-3
@@ -24,9 +24,9 @@ const (
|
|||||||
// RingInfo contains represents the Wireguard endpoint details
|
// RingInfo contains represents the Wireguard endpoint details
|
||||||
// for a Machine on a particular ring
|
// for a Machine on a particular ring
|
||||||
type RingInfo struct {
|
type RingInfo struct {
|
||||||
Ring int `toml:"ring"`
|
Ring int
|
||||||
Enabled bool `toml:"enabled,omitempty"`
|
Enabled bool
|
||||||
Keys wireguard.KeyPair `toml:"keys,omitempty"`
|
Keys wireguard.KeyPair
|
||||||
}
|
}
|
||||||
|
|
||||||
// Merge attempts to combine two RingInfo structs
|
// Merge attempts to combine two RingInfo structs
|
||||||
|
|||||||
+6
-7
@@ -88,12 +88,12 @@ func FilterMachines(m MachineIterator, cond func(*Machine) bool) (Machines, int)
|
|||||||
// Zone represents one zone in a cluster
|
// Zone represents one zone in a cluster
|
||||||
type Zone struct {
|
type Zone struct {
|
||||||
zones *Zones
|
zones *Zones
|
||||||
logger `toml:"-" json:"-" yaml:"-"`
|
logger `json:"-" yaml:"-"`
|
||||||
|
|
||||||
ID int `toml:"id"`
|
ID int
|
||||||
Name string `toml:"name"`
|
Name string
|
||||||
|
|
||||||
Machines `toml:"machines"`
|
Machines
|
||||||
}
|
}
|
||||||
|
|
||||||
func (z *Zone) String() string {
|
func (z *Zone) String() string {
|
||||||
@@ -147,9 +147,8 @@ type Zones struct {
|
|||||||
resolver resolver.Resolver
|
resolver resolver.Resolver
|
||||||
domain string
|
domain string
|
||||||
|
|
||||||
CephFSID uuid.UUID `toml:"ceph_fsid,omitempty" json:"ceph_fsid,omitempty" yaml:"ceph_fsid,omitempty"`
|
CephFSID uuid.UUID `json:"ceph_fsid,omitempty" yaml:"ceph_fsid,omitempty"`
|
||||||
|
Zones []*Zone
|
||||||
Zones []*Zone `toml:"zones"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// revive:enable:line-length-limit
|
// revive:enable:line-length-limit
|
||||||
|
|||||||
Reference in New Issue
Block a user