Compare commits
4 Commits
v0.5.5
..
b49f5e61a2
| Author | SHA1 | Date | |
|---|---|---|---|
| b49f5e61a2 | |||
| 0b135ad636 | |||
| 0a5cdb313a | |||
| e2fc4e3b9d |
Vendored
-9
@@ -1,9 +0,0 @@
|
|||||||
{
|
|
||||||
"cSpell.words": [
|
|
||||||
"ceph",
|
|
||||||
"darvaza",
|
|
||||||
"gofrs",
|
|
||||||
"jpictl",
|
|
||||||
"zerolog"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -17,6 +17,5 @@ var cfg = &Config{
|
|||||||
func (cfg *Config) LoadZones(resolve bool) (*zones.Zones, error) {
|
func (cfg *Config) LoadZones(resolve bool) (*zones.Zones, error) {
|
||||||
return zones.New(cfg.Base, cfg.Domain,
|
return zones.New(cfg.Base, cfg.Domain,
|
||||||
zones.ResolvePublicAddresses(resolve),
|
zones.ResolvePublicAddresses(resolve),
|
||||||
zones.WithLogger(log),
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-3
@@ -52,9 +52,8 @@ const encoding = YAMLEncoding
|
|||||||
|
|
||||||
// Command
|
// Command
|
||||||
var dumpCmd = &cobra.Command{
|
var dumpCmd = &cobra.Command{
|
||||||
Use: "dump",
|
Use: "dump",
|
||||||
Short: "generates a text representation of the config",
|
Short: "generates a text representation of the config",
|
||||||
PreRun: setVerbosity,
|
|
||||||
RunE: func(_ *cobra.Command, _ []string) error {
|
RunE: func(_ *cobra.Command, _ []string) error {
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
var enc Encoder
|
var enc Encoder
|
||||||
|
|||||||
+3
-8
@@ -8,20 +8,15 @@ import (
|
|||||||
|
|
||||||
// Command
|
// Command
|
||||||
var envCmd = &cobra.Command{
|
var envCmd = &cobra.Command{
|
||||||
Use: "env",
|
Use: "env",
|
||||||
Short: "generates environment variables for shell scripts",
|
Short: "generates environment variables for shell scripts",
|
||||||
PreRun: setVerbosity,
|
|
||||||
RunE: func(_ *cobra.Command, _ []string) error {
|
RunE: func(_ *cobra.Command, _ []string) error {
|
||||||
m, err := cfg.LoadZones(false)
|
m, err := cfg.LoadZones(false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
env, err := m.Env(*envExport)
|
_, err = m.Env(*envExport).WriteTo(os.Stdout)
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
_, err = env.WriteTo(os.Stdout)
|
|
||||||
return err
|
return err
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,9 +19,8 @@ var gatewayCmd = &cobra.Command{
|
|||||||
|
|
||||||
// gateway set
|
// gateway set
|
||||||
var gatewaySetCmd = &cobra.Command{
|
var gatewaySetCmd = &cobra.Command{
|
||||||
Use: "set",
|
Use: "set",
|
||||||
Short: "gateway set sets machines as gateways",
|
Short: "gateway set sets machines as gateways",
|
||||||
PreRun: setVerbosity,
|
|
||||||
RunE: func(_ *cobra.Command, args []string) error {
|
RunE: func(_ *cobra.Command, args []string) error {
|
||||||
m, err := cfg.LoadZones(false)
|
m, err := cfg.LoadZones(false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -3,9 +3,14 @@ package main
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"darvaza.org/sidecar/pkg/logger/zerolog"
|
||||||
"darvaza.org/slog"
|
"darvaza.org/slog"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
log = zerolog.New(nil, slog.Debug)
|
||||||
|
)
|
||||||
|
|
||||||
// fatal is a convenience wrapper for slog.Logger.Fatal().Print()
|
// fatal is a convenience wrapper for slog.Logger.Fatal().Print()
|
||||||
func fatal(err error, msg string, args ...any) {
|
func fatal(err error, msg string, args ...any) {
|
||||||
l := log.Fatal()
|
l := log.Fatal()
|
||||||
|
|||||||
+4
-22
@@ -2,8 +2,6 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"darvaza.org/sidecar/pkg/logger/zerolog"
|
|
||||||
"darvaza.org/slog"
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -12,29 +10,13 @@ const (
|
|||||||
CmdName = "jpictl"
|
CmdName = "jpictl"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var rootCmd = &cobra.Command{
|
||||||
log = zerolog.New(nil, slog.Error)
|
Use: CmdName,
|
||||||
verbosity int
|
Short: "control tool for jpi.cloud",
|
||||||
rootCmd = &cobra.Command{
|
}
|
||||||
Use: CmdName,
|
|
||||||
Short: "control tool for jpi.cloud",
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
if err := rootCmd.Execute(); err != nil {
|
if err := rootCmd.Execute(); err != nil {
|
||||||
fatal(err, "")
|
fatal(err, "")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
|
||||||
rootCmd.PersistentFlags().CountVarP(&verbosity, "verbosity", "v", "increase the verbosity level to Warn, Info or Debug")
|
|
||||||
}
|
|
||||||
|
|
||||||
func setVerbosity(_ *cobra.Command, _ []string) {
|
|
||||||
desired := int8(slog.Error) + int8(verbosity)
|
|
||||||
if desired > 6 {
|
|
||||||
desired = 6
|
|
||||||
}
|
|
||||||
log = log.WithLevel(slog.LogLevel(desired))
|
|
||||||
}
|
|
||||||
|
|||||||
+2
-3
@@ -6,9 +6,8 @@ import (
|
|||||||
|
|
||||||
// Command
|
// Command
|
||||||
var writeCmd = &cobra.Command{
|
var writeCmd = &cobra.Command{
|
||||||
Use: "write",
|
Use: "write",
|
||||||
Short: "rewrites all config files",
|
Short: "rewrites all config files",
|
||||||
PreRun: setVerbosity,
|
|
||||||
RunE: func(_ *cobra.Command, _ []string) error {
|
RunE: func(_ *cobra.Command, _ []string) error {
|
||||||
m, err := cfg.LoadZones(false)
|
m, err := cfg.LoadZones(false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -2,29 +2,32 @@ module git.jpi.io/amery/jpictl
|
|||||||
|
|
||||||
go 1.19
|
go 1.19
|
||||||
|
|
||||||
|
replace (
|
||||||
|
asciigoat.org/core => ../../../asciigoat.org/core
|
||||||
|
asciigoat.org/ini => ../../../asciigoat.org/ini
|
||||||
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
asciigoat.org/ini v0.2.5
|
asciigoat.org/ini v0.1.0
|
||||||
darvaza.org/core v0.9.8
|
darvaza.org/core v0.9.5
|
||||||
darvaza.org/resolver v0.5.4
|
darvaza.org/resolver v0.5.2
|
||||||
darvaza.org/sidecar v0.0.2
|
darvaza.org/sidecar v0.0.0-20230721122716-b9c54b8adbaf
|
||||||
darvaza.org/slog v0.5.3
|
darvaza.org/slog v0.5.2
|
||||||
darvaza.org/slog/handlers/discard v0.4.5
|
|
||||||
github.com/burntSushi/toml v0.3.1
|
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
|
||||||
github.com/spf13/cobra v1.7.0
|
github.com/spf13/cobra v1.7.0
|
||||||
golang.org/x/crypto v0.12.0
|
golang.org/x/crypto v0.12.0
|
||||||
gopkg.in/gcfg.v1 v1.2.3
|
|
||||||
gopkg.in/yaml.v3 v3.0.1
|
gopkg.in/yaml.v3 v3.0.1
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
asciigoat.org/core v0.3.9 // indirect
|
asciigoat.org/core v0.3.6 // indirect
|
||||||
darvaza.org/slog/handlers/filter v0.4.5 // indirect
|
darvaza.org/slog/handlers/filter v0.4.4 // indirect
|
||||||
darvaza.org/slog/handlers/zerolog v0.4.5 // indirect
|
darvaza.org/slog/handlers/zerolog v0.4.4 // indirect
|
||||||
github.com/BurntSushi/toml v1.3.2 // indirect
|
github.com/BurntSushi/toml v1.3.2 // indirect
|
||||||
github.com/chavacava/garif v0.1.0 // indirect
|
github.com/chavacava/garif v0.0.0-20230608123814-4bd63c2919ab // indirect
|
||||||
github.com/fatih/color v1.15.0 // indirect
|
github.com/fatih/color v1.15.0 // indirect
|
||||||
github.com/fatih/structtag v1.2.0 // indirect
|
github.com/fatih/structtag v1.2.0 // indirect
|
||||||
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
||||||
@@ -41,8 +44,7 @@ require (
|
|||||||
github.com/spf13/pflag v1.0.5 // indirect
|
github.com/spf13/pflag v1.0.5 // indirect
|
||||||
golang.org/x/mod v0.12.0 // indirect
|
golang.org/x/mod v0.12.0 // indirect
|
||||||
golang.org/x/net v0.14.0 // indirect
|
golang.org/x/net v0.14.0 // indirect
|
||||||
golang.org/x/sys v0.12.0 // indirect
|
golang.org/x/sys v0.11.0 // indirect
|
||||||
golang.org/x/text v0.13.0 // indirect
|
golang.org/x/text v0.12.0 // indirect
|
||||||
golang.org/x/tools v0.12.0 // indirect
|
golang.org/x/tools v0.12.0 // indirect
|
||||||
gopkg.in/warnings.v0 v0.1.2 // indirect
|
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,27 +1,21 @@
|
|||||||
asciigoat.org/core v0.3.9 h1:hgDDz4ecm3ZvehX++m8A/IzAt+B5oDPiRtxatzfUHPQ=
|
darvaza.org/core v0.9.5 h1:sS5pZFwicaxJIQixEiqkMr9GknVHYL+EbKDMkR/4jDM=
|
||||||
asciigoat.org/core v0.3.9/go.mod h1:CAaHwyw8MpAq4a1MYtN2dxJrsK+hmIdW50OndaQZYPI=
|
darvaza.org/core v0.9.5/go.mod h1:O3tHBMlw+xB47uGh5CUx7dXAujBAMmD8BCRFPZmIw54=
|
||||||
asciigoat.org/ini v0.2.5 h1:4gRIp9rU+XQt8+HMqZO5R7GavMv9Yl2+N+je6djDIAE=
|
darvaza.org/resolver v0.5.2 h1:VjHhEr/MJBszeDb7tYlXQ9Bsyh4xrDR7Sd10WAmPD6k=
|
||||||
asciigoat.org/ini v0.2.5/go.mod h1:gmXzJ9XFqf1NLk5nQkj04USQ4tMtdRJHNQX6vp3DzjU=
|
darvaza.org/resolver v0.5.2/go.mod h1:fFvsVPEFeMzUIWlLG47Go/6uJYtRLb9R8HIgYg3uaxE=
|
||||||
darvaza.org/core v0.9.8 h1:luLxgfUc2pzuusYPo/Z/dC/qr9XZPKpSQw8/kS7zNUM=
|
darvaza.org/sidecar v0.0.0-20230721122716-b9c54b8adbaf h1:ya5ZQicBb/GWll3rlqra8No7oJXks7y1m/cJGYBypv4=
|
||||||
darvaza.org/core v0.9.8/go.mod h1:Dbme64naxeshQfxcVJX9ZT7AiGyIY8kldfuELVtf8mw=
|
darvaza.org/sidecar v0.0.0-20230721122716-b9c54b8adbaf/go.mod h1:by+bPsMa7Rxc/ZYG1qBunrtKocv/DkrPBmyFlmq/j2Q=
|
||||||
darvaza.org/resolver v0.5.4 h1:dlSBNV14yYsp7Kg7ipwYOMNsLbrpeXa8Z0HBTa0Ryxs=
|
darvaza.org/slog v0.5.2 h1:8TG1WyHjOyh2vW6t3pjzZVaWzpko5MIIpeI7LWqHFvs=
|
||||||
darvaza.org/resolver v0.5.4/go.mod h1:vHMkQUmHjaetFqG2ZLZJiQHsXEMGoTOFGm+NXwfndhE=
|
darvaza.org/slog v0.5.2/go.mod h1:HAkEpxTA/mkiLNUXJo5qsCh8EVCtA3evje8GAaCDWHI=
|
||||||
darvaza.org/sidecar v0.0.2 h1:4H8FUxc43kkLjxdShN1CoxLTcoHQsZjDVwm7kt6eIK0=
|
darvaza.org/slog/handlers/filter v0.4.4 h1:b2e2T9fQzMdJ0ia+f6b7kw9/T9GFwhFCKob/2tqhGGU=
|
||||||
darvaza.org/sidecar v0.0.2/go.mod h1:yFC3Qt3j+uS7n9CMpLxwrA68z+FNJhENoenBc9zBJJo=
|
darvaza.org/slog/handlers/filter v0.4.4/go.mod h1:cQlJWuolB6guLug09sX/8Zrzct++M6SPCGvXR37E7Cc=
|
||||||
darvaza.org/slog v0.5.3 h1:sQzmZXgqRh9oFMKBwEYrEpucLvKJVZxaxa2bHIA6GJ0=
|
darvaza.org/slog/handlers/zerolog v0.4.4 h1:OR1ASvH1fBCq3t85t4OU6oJPPuqMB1tsDoSpsh6HVJU=
|
||||||
darvaza.org/slog v0.5.3/go.mod h1:59d+yi+C7gn4pDDuwbbOKawERpdXthFFk1Yc+Sv6XB0=
|
darvaza.org/slog/handlers/zerolog v0.4.4/go.mod h1:t60TeEbFcMLo74CkXC2S0rKlnwF4ixZyBR4fqIJV1GE=
|
||||||
darvaza.org/slog/handlers/discard v0.4.5 h1:RRykOItNolHyiUav57lG/GFBL33rcljoa0nWTpY+T0g=
|
|
||||||
darvaza.org/slog/handlers/discard v0.4.5/go.mod h1:HYHfISQjMqcPbPoPZ92ib/u7s9JcXvF6OaygpPFwdF8=
|
|
||||||
darvaza.org/slog/handlers/filter v0.4.5 h1:CX1bMzldd67e3y3s3Sh4jK8Lyo0WMvTGBB2lD315jhc=
|
|
||||||
darvaza.org/slog/handlers/filter v0.4.5/go.mod h1:OuH9rHYg9CIErTJCZliMnFexBfP/HJ9PZ1V1VwSCZ1g=
|
|
||||||
darvaza.org/slog/handlers/zerolog v0.4.5 h1:W4cgGORx4wImr+RL96CWSQGTdkZzKX6YHXPSYJvdoB4=
|
|
||||||
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 h1:Hu1cOEC2qtKULZJCzym5tyA35bZr3HREuolgiAzMlhY=
|
||||||
github.com/burntSushi/toml v0.3.1/go.mod h1:sGTquCpRYr9McuHdv0m6YKIhx8DJGJa4t04/Y9pfSio=
|
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.0.0-20230608123814-4bd63c2919ab h1:5JxePczlyGAtj6R1MUEFZ/UFud6FfsOejq7xLC2ZIb0=
|
||||||
github.com/chavacava/garif v0.1.0/go.mod h1:XMyYCkEL58DF0oyW4qDjjnPWONs2HBqYKI+UIPD+Gww=
|
github.com/chavacava/garif v0.0.0-20230608123814-4bd63c2919ab/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=
|
||||||
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
@@ -92,18 +86,14 @@ golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBc
|
|||||||
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o=
|
golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM=
|
||||||
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
|
golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc=
|
||||||
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
||||||
golang.org/x/tools v0.12.0 h1:YW6HUoUmYBpwSgyaGaZq1fHjrBjX1rlpZ54T6mu2kss=
|
golang.org/x/tools v0.12.0 h1:YW6HUoUmYBpwSgyaGaZq1fHjrBjX1rlpZ54T6mu2kss=
|
||||||
golang.org/x/tools v0.12.0/go.mod h1:Sc0INKfu04TlqNoRA1hgpFZbhYXHPr4V5DzpSBTPqQM=
|
golang.org/x/tools v0.12.0/go.mod h1:Sc0INKfu04TlqNoRA1hgpFZbhYXHPr4V5DzpSBTPqQM=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/gcfg.v1 v1.2.3 h1:m8OOJ4ccYHnx2f4gQwpno8nAX5OGOh7RLaaz0pj3Ogs=
|
|
||||||
gopkg.in/gcfg.v1 v1.2.3/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o=
|
|
||||||
gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME=
|
|
||||||
gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI=
|
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
|
|||||||
+35
-26
@@ -2,10 +2,8 @@ package ceph
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
|
||||||
"io"
|
"io"
|
||||||
"net/netip"
|
"net/netip"
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/gofrs/uuid/v5"
|
"github.com/gofrs/uuid/v5"
|
||||||
|
|
||||||
@@ -14,41 +12,52 @@ import (
|
|||||||
|
|
||||||
// Config represents a ceph.conf file
|
// Config represents a ceph.conf file
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Global GlobalConfig `ini:"global"`
|
Global GlobalConfig
|
||||||
|
}
|
||||||
|
|
||||||
|
// WriteTo writes a Wireguard [Config] onto the provided [io.Writer]
|
||||||
|
func (*Config) WriteTo(w io.Writer) (int64, error) {
|
||||||
|
var buf bytes.Buffer
|
||||||
|
|
||||||
|
return buf.WriteTo(w)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GlobalConfig represents the [global] section of a ceph.conf file
|
// GlobalConfig represents the [global] section of a ceph.conf file
|
||||||
type GlobalConfig struct {
|
type GlobalConfig struct {
|
||||||
FSID uuid.UUID `ini:"fsid"`
|
FSID uuid.UUID
|
||||||
Monitors []string `ini:"mon_initial_members,comma"`
|
Monitors []string
|
||||||
MonitorsAddr []netip.Addr `ini:"mon_host,comma"`
|
MonitorsAddr []netip.Addr
|
||||||
ClusterNetwork netip.Prefix `ini:"cluster_network"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// WriteTo writes a Wireguard [Config] onto the provided [io.Writer]
|
type intermediateConfig struct {
|
||||||
func (cfg *Config) WriteTo(w io.Writer) (int64, error) {
|
Global intermediateGlobalConfig
|
||||||
var buf bytes.Buffer
|
|
||||||
|
|
||||||
writeGlobalToBuffer(&buf, &cfg.Global)
|
|
||||||
return buf.WriteTo(w)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func writeGlobalToBuffer(w *bytes.Buffer, c *GlobalConfig) {
|
func (p intermediateConfig) Export() (*Config, error) {
|
||||||
_, _ = w.WriteString("[global]\n")
|
var out Config
|
||||||
_, _ = fmt.Fprintf(w, "%s = %s\n", "fsid", c.FSID.String())
|
var err error
|
||||||
_, _ = fmt.Fprintf(w, "%s = %s\n", "mon_initial_members", strings.Join(c.Monitors, ", "))
|
|
||||||
_, _ = fmt.Fprintf(w, "%s = %s\n", "mon_host", joinAddrs(c.MonitorsAddr, ", "))
|
|
||||||
_, _ = fmt.Fprintf(w, "%s = %s\n", "cluster_network", c.ClusterNetwork.String())
|
|
||||||
}
|
|
||||||
|
|
||||||
func joinAddrs(addrs []netip.Addr, sep string) string {
|
// [global]
|
||||||
s := make([]string, len(addrs))
|
out.Global, err = p.Global.Export()
|
||||||
|
if err != nil {
|
||||||
for i, addr := range addrs {
|
return nil, err
|
||||||
s[i] = addr.String()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return strings.Join(s, sep)
|
return &out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type intermediateGlobalConfig struct {
|
||||||
|
FSID uuid.UUID
|
||||||
|
MonInitialMembers string
|
||||||
|
MonHost string
|
||||||
|
ClusterNetwork string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (intermediateGlobalConfig) Export() (GlobalConfig, error) {
|
||||||
|
var out GlobalConfig
|
||||||
|
var err error
|
||||||
|
|
||||||
|
return out, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewConfigFromReader parses the ceph.conf file
|
// NewConfigFromReader parses the ceph.conf file
|
||||||
|
|||||||
@@ -1,110 +0,0 @@
|
|||||||
package ceph
|
|
||||||
|
|
||||||
import (
|
|
||||||
"io/fs"
|
|
||||||
"net/netip"
|
|
||||||
|
|
||||||
"asciigoat.org/ini/basic"
|
|
||||||
"asciigoat.org/ini/parser"
|
|
||||||
|
|
||||||
"darvaza.org/core"
|
|
||||||
)
|
|
||||||
|
|
||||||
var sectionMap = map[string]func(*Config, *basic.Section) error{
|
|
||||||
"global": loadGlobalConfSection,
|
|
||||||
}
|
|
||||||
|
|
||||||
func loadConfSection(out *Config, src *basic.Section) error {
|
|
||||||
h, ok := sectionMap[src.Key]
|
|
||||||
if !ok {
|
|
||||||
return core.Wrapf(fs.ErrInvalid, "unknown section %q", src.Key)
|
|
||||||
}
|
|
||||||
|
|
||||||
return h(out, src)
|
|
||||||
}
|
|
||||||
|
|
||||||
func loadGlobalConfSection(out *Config, src *basic.Section) error {
|
|
||||||
var cfg GlobalConfig
|
|
||||||
|
|
||||||
for _, field := range src.Fields {
|
|
||||||
if err := loadGlobalConfField(&cfg, field); err != nil {
|
|
||||||
return core.Wrap(err, "global")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
out.Global = cfg
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// revive:disable:cyclomatic
|
|
||||||
// revive:disable:cognitive-complexity
|
|
||||||
|
|
||||||
func loadGlobalConfField(cfg *GlobalConfig, field basic.Field) error {
|
|
||||||
// revive:enable:cyclomatic
|
|
||||||
// revive:enable:cognitive-complexity
|
|
||||||
|
|
||||||
// TODO: refactor when asciigoat's ini parser learns to do reflection
|
|
||||||
|
|
||||||
switch field.Key {
|
|
||||||
case "fsid":
|
|
||||||
if !core.IsZero(cfg.FSID) {
|
|
||||||
return core.Wrapf(fs.ErrInvalid, "duplicate field %q", field.Key)
|
|
||||||
}
|
|
||||||
|
|
||||||
err := cfg.FSID.UnmarshalText([]byte(field.Value))
|
|
||||||
switch {
|
|
||||||
case err != nil:
|
|
||||||
return core.Wrap(err, field.Key)
|
|
||||||
default:
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
case "mon_host":
|
|
||||||
entries, _ := parser.SplitCommaArray(field.Value)
|
|
||||||
for _, s := range entries {
|
|
||||||
var addr netip.Addr
|
|
||||||
|
|
||||||
if err := addr.UnmarshalText([]byte(s)); err != nil {
|
|
||||||
return core.Wrap(err, field.Key)
|
|
||||||
}
|
|
||||||
|
|
||||||
cfg.MonitorsAddr = append(cfg.MonitorsAddr, addr)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
case "mon_initial_members":
|
|
||||||
entries, _ := parser.SplitCommaArray(field.Value)
|
|
||||||
cfg.Monitors = append(cfg.Monitors, entries...)
|
|
||||||
return nil
|
|
||||||
case "cluster_network":
|
|
||||||
if !core.IsZero(cfg.ClusterNetwork) {
|
|
||||||
err := core.Wrap(fs.ErrInvalid, "fields before the first section")
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
err := cfg.ClusterNetwork.UnmarshalText([]byte(field.Value))
|
|
||||||
switch {
|
|
||||||
case err != nil:
|
|
||||||
return core.Wrap(err, field.Key)
|
|
||||||
default:
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func newConfigFromDocument(doc *basic.Document) (*Config, error) {
|
|
||||||
var out Config
|
|
||||||
|
|
||||||
if len(doc.Global) > 0 {
|
|
||||||
err := core.Wrap(fs.ErrInvalid, "fields before the first section")
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
for i := range doc.Sections {
|
|
||||||
src := &doc.Sections[i]
|
|
||||||
if err := loadConfSection(&out, src); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return &out, nil
|
|
||||||
}
|
|
||||||
@@ -10,8 +10,8 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"text/template"
|
"text/template"
|
||||||
|
|
||||||
|
"asciigoat.org/ini/basic"
|
||||||
"darvaza.org/core"
|
"darvaza.org/core"
|
||||||
"gopkg.in/gcfg.v1"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var configTemplate = template.Must(template.New("config").Funcs(template.FuncMap{
|
var configTemplate = template.Must(template.New("config").Funcs(template.FuncMap{
|
||||||
@@ -249,11 +249,15 @@ func (v *intermediateConfig) PeersCount() (int, bool) {
|
|||||||
|
|
||||||
// NewConfigFromReader parses a wgN.conf file
|
// NewConfigFromReader parses a wgN.conf file
|
||||||
func NewConfigFromReader(r io.Reader) (*Config, error) {
|
func NewConfigFromReader(r io.Reader) (*Config, error) {
|
||||||
temp := &intermediateConfig{}
|
doc, err := basic.Decode(r)
|
||||||
|
if err != nil {
|
||||||
if err := gcfg.ReadInto(temp, r); err != nil {
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return temp.Export()
|
cfg, err := newConfigFromDocument(doc)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return cfg, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,28 +2,10 @@ package zones
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"net/netip"
|
|
||||||
"sort"
|
|
||||||
|
|
||||||
"darvaza.org/core"
|
|
||||||
"github.com/gofrs/uuid/v5"
|
|
||||||
|
|
||||||
"git.jpi.io/amery/jpictl/pkg/ceph"
|
"git.jpi.io/amery/jpictl/pkg/ceph"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetCephFSID returns our Ceph's FSID
|
|
||||||
func (m *Zones) GetCephFSID() (uuid.UUID, error) {
|
|
||||||
if core.IsZero(m.CephFSID) {
|
|
||||||
// generate one
|
|
||||||
v, err := uuid.NewV4()
|
|
||||||
if err != nil {
|
|
||||||
return uuid.Nil, err
|
|
||||||
}
|
|
||||||
m.CephFSID = v
|
|
||||||
}
|
|
||||||
return m.CephFSID, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetCephConfig reads the ceph.conf file
|
// GetCephConfig reads the ceph.conf file
|
||||||
func (m *Zones) GetCephConfig() (*ceph.Config, error) {
|
func (m *Zones) GetCephConfig() (*ceph.Config, error) {
|
||||||
data, err := m.ReadFile("ceph.conf")
|
data, err := m.ReadFile("ceph.conf")
|
||||||
@@ -46,77 +28,3 @@ func (m *Zones) WriteCephConfig(cfg *ceph.Config) error {
|
|||||||
_, err = cfg.WriteTo(f)
|
_, err = cfg.WriteTo(f)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// GenCephConfig prepares a ceph.Config using the cluster information
|
|
||||||
func (m *Zones) GenCephConfig() (*ceph.Config, error) {
|
|
||||||
fsid, err := m.GetCephFSID()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
cfg := &ceph.Config{
|
|
||||||
Global: ceph.GlobalConfig{
|
|
||||||
FSID: fsid,
|
|
||||||
ClusterNetwork: netip.PrefixFrom(
|
|
||||||
netip.AddrFrom4([4]byte{10, 0, 0, 0}),
|
|
||||||
8,
|
|
||||||
),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
m.ForEachZone(func(z *Zone) bool {
|
|
||||||
for _, p := range z.GetCephMonitors() {
|
|
||||||
addr, _ := RingOneAddress(z.ID, p.ID)
|
|
||||||
|
|
||||||
cfg.Global.Monitors = append(cfg.Global.Monitors, p.Name)
|
|
||||||
cfg.Global.MonitorsAddr = append(cfg.Global.MonitorsAddr, addr)
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
})
|
|
||||||
|
|
||||||
return cfg, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetCephMonitors returns the set of Ceph monitors on
|
|
||||||
// the zone
|
|
||||||
func (z *Zone) GetCephMonitors() Machines {
|
|
||||||
var mons Machines
|
|
||||||
var first, second *Machine
|
|
||||||
|
|
||||||
z.ForEachMachine(func(p *Machine) bool {
|
|
||||||
switch {
|
|
||||||
case p.CephMonitor:
|
|
||||||
// it is a monitor
|
|
||||||
mons = append(mons, p)
|
|
||||||
case len(mons) > 0:
|
|
||||||
// zone has a monitor
|
|
||||||
case first == nil && !p.IsGateway():
|
|
||||||
// first option for monitor
|
|
||||||
first = p
|
|
||||||
case second == nil:
|
|
||||||
// second option for monitor
|
|
||||||
second = p
|
|
||||||
}
|
|
||||||
|
|
||||||
return false
|
|
||||||
})
|
|
||||||
|
|
||||||
switch {
|
|
||||||
case len(mons) > 0:
|
|
||||||
// ready
|
|
||||||
case first != nil:
|
|
||||||
// make first option our monitor
|
|
||||||
first.CephMonitor = true
|
|
||||||
mons = append(mons, first)
|
|
||||||
case second != nil:
|
|
||||||
// make second option our monitor
|
|
||||||
second.CephMonitor = true
|
|
||||||
mons = append(mons, second)
|
|
||||||
default:
|
|
||||||
// zone without machines??
|
|
||||||
panic("unreachable")
|
|
||||||
}
|
|
||||||
|
|
||||||
sort.Sort(mons)
|
|
||||||
return mons
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,103 +0,0 @@
|
|||||||
package zones
|
|
||||||
|
|
||||||
import (
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"darvaza.org/slog"
|
|
||||||
"git.jpi.io/amery/jpictl/pkg/ceph"
|
|
||||||
)
|
|
||||||
|
|
||||||
type cephScanTODO struct {
|
|
||||||
names map[string]bool
|
|
||||||
addrs map[string]bool
|
|
||||||
}
|
|
||||||
|
|
||||||
func (todo *cephScanTODO) checkMachine(p *Machine) bool {
|
|
||||||
// on ceph all addresses are ring1
|
|
||||||
ring1, _ := RingOneAddress(p.Zone(), p.ID)
|
|
||||||
addr := ring1.String()
|
|
||||||
|
|
||||||
if _, found := todo.names[p.Name]; found {
|
|
||||||
// found on the TODO by name
|
|
||||||
todo.names[p.Name] = true
|
|
||||||
todo.addrs[addr] = true
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
if _, found := todo.addrs[addr]; found {
|
|
||||||
// found on the TODO by address
|
|
||||||
todo.names[p.Name] = true
|
|
||||||
todo.addrs[addr] = true
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
func (todo *cephScanTODO) LogMissing(log slog.Logger) {
|
|
||||||
for name, found := range todo.names {
|
|
||||||
if !found {
|
|
||||||
log.Warn().
|
|
||||||
WithField("subsystem", "ceph").
|
|
||||||
WithField("monitor", name).
|
|
||||||
Print("unknown monitor")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for addr, found := range todo.addrs {
|
|
||||||
if !found {
|
|
||||||
log.Warn().
|
|
||||||
WithField("subsystem", "ceph").
|
|
||||||
WithField("monitor", addr).
|
|
||||||
Print("unknown monitor")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func newCephScanTODO(cfg *ceph.Config) *cephScanTODO {
|
|
||||||
todo := &cephScanTODO{
|
|
||||||
names: make(map[string]bool),
|
|
||||||
addrs: make(map[string]bool),
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, name := range cfg.Global.Monitors {
|
|
||||||
todo.names[name] = false
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, addr := range cfg.Global.MonitorsAddr {
|
|
||||||
todo.addrs[addr.String()] = false
|
|
||||||
}
|
|
||||||
|
|
||||||
return todo
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *Zones) scanCephMonitors(_ *ScanOptions) error {
|
|
||||||
cfg, err := m.GetCephConfig()
|
|
||||||
switch {
|
|
||||||
case os.IsNotExist(err):
|
|
||||||
err = nil
|
|
||||||
case err != nil:
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if cfg != nil {
|
|
||||||
// store FSID
|
|
||||||
m.CephFSID = cfg.Global.FSID
|
|
||||||
|
|
||||||
// flag monitors based on config
|
|
||||||
todo := newCephScanTODO(cfg)
|
|
||||||
m.ForEachMachine(func(p *Machine) bool {
|
|
||||||
p.CephMonitor = todo.checkMachine(p)
|
|
||||||
return false
|
|
||||||
})
|
|
||||||
|
|
||||||
todo.LogMissing(m.log)
|
|
||||||
}
|
|
||||||
|
|
||||||
// make sure every zone has one
|
|
||||||
m.ForEachZone(func(z *Zone) bool {
|
|
||||||
_ = z.GetCephMonitors()
|
|
||||||
return false
|
|
||||||
})
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
+3
-67
@@ -11,24 +11,15 @@ import (
|
|||||||
type Env struct {
|
type Env struct {
|
||||||
ZoneIterator
|
ZoneIterator
|
||||||
|
|
||||||
cephFSID string
|
export bool
|
||||||
export bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Env returns a shell environment factory
|
// Env returns a shell environment factory
|
||||||
func (m *Zones) Env(export bool) (*Env, error) {
|
func (m *Zones) Env(export bool) *Env {
|
||||||
fsid, err := m.GetCephFSID()
|
return &Env{
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
env := &Env{
|
|
||||||
ZoneIterator: m,
|
ZoneIterator: m,
|
||||||
cephFSID: fsid.String(),
|
|
||||||
export: export,
|
export: export,
|
||||||
}
|
}
|
||||||
|
|
||||||
return env, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Zones returns the list of Zone IDs
|
// Zones returns the list of Zone IDs
|
||||||
@@ -47,12 +38,7 @@ func (m *Env) Zones() []int {
|
|||||||
func (m *Env) WriteTo(w io.Writer) (int64, error) {
|
func (m *Env) WriteTo(w io.Writer) (int64, error) {
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
|
|
||||||
if m.cephFSID != "" {
|
|
||||||
m.writeEnvVar(&buf, m.cephFSID, "FSID")
|
|
||||||
}
|
|
||||||
|
|
||||||
m.writeEnvVarInts(&buf, m.Zones(), "ZONES")
|
m.writeEnvVarInts(&buf, m.Zones(), "ZONES")
|
||||||
|
|
||||||
m.ForEachZone(func(z *Zone) bool {
|
m.ForEachZone(func(z *Zone) bool {
|
||||||
m.writeEnvZone(&buf, z)
|
m.writeEnvZone(&buf, z)
|
||||||
return false
|
return false
|
||||||
@@ -73,15 +59,6 @@ func (m *Env) writeEnvZone(w io.Writer, z *Zone) {
|
|||||||
// ZONE{zoneID}_GW
|
// ZONE{zoneID}_GW
|
||||||
gateways, _ := z.GatewayIDs()
|
gateways, _ := z.GatewayIDs()
|
||||||
m.writeEnvVarInts(w, gateways, "ZONE%v_%s", zoneID, "GW")
|
m.writeEnvVarInts(w, gateways, "ZONE%v_%s", zoneID, "GW")
|
||||||
|
|
||||||
// Ceph
|
|
||||||
monitors := z.GetCephMonitors()
|
|
||||||
// MON{zoneID}_NAME
|
|
||||||
m.writeEnvVar(w, genEnvZoneCephMonNames(monitors), "MON%v_%s", zoneID, "NAME")
|
|
||||||
// MON{zoneID}_IP
|
|
||||||
m.writeEnvVar(w, genEnvZoneCephMonIPs(monitors), "MON%v_%s", zoneID, "IP")
|
|
||||||
// MON{zoneID}_ID
|
|
||||||
m.writeEnvVar(w, genEnvZoneCephMonIDs(monitors), "MON%v_%s", zoneID, "ID")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Env) writeEnvVarInts(w io.Writer, value []int, name string, args ...any) {
|
func (m *Env) writeEnvVarInts(w io.Writer, value []int, name string, args ...any) {
|
||||||
@@ -134,44 +111,3 @@ func genEnvZoneNodes(z *Zone) string {
|
|||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func genEnvZoneCephMonNames(m Machines) string {
|
|
||||||
var buf strings.Builder
|
|
||||||
m.ForEachMachine(func(p *Machine) bool {
|
|
||||||
if buf.Len() > 0 {
|
|
||||||
_, _ = buf.WriteRune(' ')
|
|
||||||
}
|
|
||||||
_, _ = buf.WriteString(p.Name)
|
|
||||||
|
|
||||||
return false
|
|
||||||
})
|
|
||||||
return buf.String()
|
|
||||||
}
|
|
||||||
|
|
||||||
func genEnvZoneCephMonIPs(m Machines) string {
|
|
||||||
var buf strings.Builder
|
|
||||||
m.ForEachMachine(func(p *Machine) bool {
|
|
||||||
addr, _ := RingOneAddress(p.Zone(), p.ID)
|
|
||||||
|
|
||||||
if buf.Len() > 0 {
|
|
||||||
_, _ = buf.WriteRune(' ')
|
|
||||||
}
|
|
||||||
_, _ = buf.WriteString(addr.String())
|
|
||||||
|
|
||||||
return false
|
|
||||||
})
|
|
||||||
return buf.String()
|
|
||||||
}
|
|
||||||
|
|
||||||
func genEnvZoneCephMonIDs(m Machines) string {
|
|
||||||
var buf strings.Builder
|
|
||||||
m.ForEachMachine(func(p *Machine) bool {
|
|
||||||
if buf.Len() > 0 {
|
|
||||||
_, _ = buf.WriteRune(' ')
|
|
||||||
}
|
|
||||||
_, _ = fmt.Fprintf(&buf, "%v", p.ID)
|
|
||||||
|
|
||||||
return false
|
|
||||||
})
|
|
||||||
return buf.String()
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
package zones
|
|
||||||
|
|
||||||
import "errors"
|
|
||||||
|
|
||||||
var (
|
|
||||||
// ErrInvalidName indicates the name isn't valid
|
|
||||||
ErrInvalidName = errors.New("invalid name")
|
|
||||||
|
|
||||||
// ErrUnknownNode indicates there is a reference to a node
|
|
||||||
// we don't have on the tree
|
|
||||||
ErrUnknownNode = errors.New("node does not exist")
|
|
||||||
|
|
||||||
// ErrInvalidNode indicates the nodes can't be used for
|
|
||||||
// the intended purpose
|
|
||||||
ErrInvalidNode = errors.New("invalid node")
|
|
||||||
)
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
package zones
|
|
||||||
|
|
||||||
import "darvaza.org/slog"
|
|
||||||
|
|
||||||
type logger interface {
|
|
||||||
withDebug() (slog.Logger, bool)
|
|
||||||
withInfo() (slog.Logger, bool)
|
|
||||||
|
|
||||||
debug() slog.Logger
|
|
||||||
info() slog.Logger
|
|
||||||
warn(error) slog.Logger
|
|
||||||
error(error) slog.Logger
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
|
||||||
_ logger = (*Zones)(nil)
|
|
||||||
)
|
|
||||||
|
|
||||||
func (z *Zones) withDebug() (slog.Logger, bool) {
|
|
||||||
return z.debug().WithEnabled()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (z *Zones) withInfo() (slog.Logger, bool) {
|
|
||||||
return z.debug().WithEnabled()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (z *Zones) debug() slog.Logger {
|
|
||||||
return z.log.Debug()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (z *Zones) info() slog.Logger {
|
|
||||||
return z.log.Info()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (z *Zones) warn(err error) slog.Logger {
|
|
||||||
l := z.log.Warn()
|
|
||||||
if err != nil {
|
|
||||||
l = l.WithField(slog.ErrorFieldName, err)
|
|
||||||
}
|
|
||||||
return l
|
|
||||||
}
|
|
||||||
|
|
||||||
func (z *Zones) error(err error) slog.Logger {
|
|
||||||
l := z.log.Error()
|
|
||||||
if err != nil {
|
|
||||||
l = l.WithField(slog.ErrorFieldName, err)
|
|
||||||
}
|
|
||||||
return l
|
|
||||||
}
|
|
||||||
@@ -9,16 +9,12 @@ 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:"-"`
|
|
||||||
|
|
||||||
ID int `toml:"id"`
|
ID int `toml:"id"`
|
||||||
Name string `toml:"-" json:"-" yaml:"-"`
|
Name string `toml:"-" json:"-" yaml:"-"`
|
||||||
|
|
||||||
PublicAddresses []netip.Addr `toml:"public,omitempty" json:"public,omitempty" yaml:"public,omitempty"`
|
PublicAddresses []netip.Addr `toml:"public,omitempty" json:"public,omitempty" yaml:"public,omitempty"`
|
||||||
Rings []*RingInfo `toml:"rings,omitempty" json:"rings,omitempty" yaml:"rings,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"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// revive:enable:line-length-limit
|
// revive:enable:line-length-limit
|
||||||
|
|||||||
+10
-22
@@ -2,7 +2,6 @@ package zones
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
@@ -122,30 +121,23 @@ func (m *Machine) applyWireguardConfig(ring int, wg *wireguard.Config) error {
|
|||||||
addr := wg.GetAddress()
|
addr := wg.GetAddress()
|
||||||
zoneID, nodeID, ok := Rings[ring].Decode(addr)
|
zoneID, nodeID, ok := Rings[ring].Decode(addr)
|
||||||
if !ok {
|
if !ok {
|
||||||
return fmt.Errorf("%s: invalid address", addr)
|
return fmt.Errorf("%s: invalid wg%v address: %s", m.Name, ring, addr)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := m.applyZoneNodeID(zoneID, nodeID); err != nil {
|
if err := m.applyZoneNodeID(zoneID, nodeID); err != nil {
|
||||||
return core.Wrapf(err, "%s: invalid address", addr)
|
err = core.Wrapf(err, "%s: wg%v:%s", m.Name, ring, addr)
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := m.applyWireguardInterfaceConfig(ring, wg.Interface); err != nil {
|
if err := m.applyWireguardInterfaceConfig(ring, wg.Interface); err != nil {
|
||||||
return core.Wrap(err, "interface")
|
err = core.Wrapf(err, "%s: wg%v:%s", m.Name, ring, addr)
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, peer := range wg.Peer {
|
for _, peer := range wg.Peer {
|
||||||
err := m.applyWireguardPeerConfig(ring, peer)
|
if err := m.applyWireguardPeerConfig(ring, peer); err != nil {
|
||||||
switch {
|
err = core.Wrapf(err, "%s: wg%v:%s", m.Name, ring, addr)
|
||||||
case errors.Is(err, ErrUnknownNode):
|
return err
|
||||||
// ignore unknown peers
|
|
||||||
m.warn(nil).
|
|
||||||
WithField("subsystem", "wireguard").
|
|
||||||
WithField("node", m.Name).
|
|
||||||
WithField("peer", peer.Endpoint.Host).
|
|
||||||
WithField("ring", ring).
|
|
||||||
Print("ignoring unknown endpoint")
|
|
||||||
case err != nil:
|
|
||||||
return core.Wrap(err, "peer")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -166,10 +158,6 @@ func (m *Machine) applyRingInfo(ring int, new *RingInfo) error {
|
|||||||
cur, _ := m.getRingInfo(ring)
|
cur, _ := m.getRingInfo(ring)
|
||||||
if cur == nil {
|
if cur == nil {
|
||||||
// first, append
|
// first, append
|
||||||
m.debug().
|
|
||||||
WithField("node", m.Name).
|
|
||||||
WithField("ring", ring).
|
|
||||||
Print("found")
|
|
||||||
m.Rings = append(m.Rings, new)
|
m.Rings = append(m.Rings, new)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -195,10 +183,8 @@ func (m *Machine) applyWireguardPeerConfig(ring int, pc wireguard.PeerConfig) er
|
|||||||
switch {
|
switch {
|
||||||
case !found:
|
case !found:
|
||||||
// unknown
|
// unknown
|
||||||
return core.Wrap(ErrUnknownNode, pc.Endpoint.Host)
|
|
||||||
case ring == 1 && m.zone != peer.zone:
|
case ring == 1 && m.zone != peer.zone:
|
||||||
// invalid zone
|
// invalid zone
|
||||||
return core.Wrap(ErrInvalidNode, peer.Name)
|
|
||||||
default:
|
default:
|
||||||
// apply RingInfo
|
// apply RingInfo
|
||||||
ri := &RingInfo{
|
ri := &RingInfo{
|
||||||
@@ -211,6 +197,8 @@ func (m *Machine) applyWireguardPeerConfig(ring int, pc wireguard.PeerConfig) er
|
|||||||
|
|
||||||
return peer.applyRingInfo(ring, ri)
|
return peer.applyRingInfo(ring, ri)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return fmt.Errorf("%q: invalid peer endpoint", pc.Endpoint.Host)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Machine) applyZoneNodeID(zoneID, nodeID int) error {
|
func (m *Machine) applyZoneNodeID(zoneID, nodeID int) error {
|
||||||
|
|||||||
@@ -4,10 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"net/netip"
|
"net/netip"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"darvaza.org/core"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// LookupNetIP uses the DNS Resolver to get the public addresses associated
|
// LookupNetIP uses the DNS Resolver to get the public addresses associated
|
||||||
@@ -33,32 +30,21 @@ func (m *Machine) UpdatePublicAddresses() error {
|
|||||||
|
|
||||||
func (m *Machine) init() error {
|
func (m *Machine) init() error {
|
||||||
if err := m.setID(); err != nil {
|
if err := m.setID(); err != nil {
|
||||||
return core.Wrap(err, m.Name)
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := 0; i < RingsCount; i++ {
|
for i := 0; i < RingsCount; i++ {
|
||||||
if err := m.tryReadWireguardKeys(i); err != nil {
|
if err := m.tryReadWireguardKeys(i); err != nil {
|
||||||
return core.Wrap(err, m.Name)
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Machine) setID() error {
|
func (m *Machine) setID() error {
|
||||||
zoneName := m.zone.Name
|
zoneName := m.zone.Name
|
||||||
|
suffix := m.Name[len(zoneName)+1:]
|
||||||
|
|
||||||
l := len(zoneName)
|
|
||||||
switch {
|
|
||||||
case len(m.Name) < l+2:
|
|
||||||
return ErrInvalidName
|
|
||||||
case !strings.HasPrefix(m.Name, zoneName):
|
|
||||||
return ErrInvalidName
|
|
||||||
case m.Name[l] != '-':
|
|
||||||
return ErrInvalidName
|
|
||||||
}
|
|
||||||
|
|
||||||
suffix := m.Name[l+1:]
|
|
||||||
id, err := strconv.ParseInt(suffix, 10, 8)
|
id, err := strconv.ParseInt(suffix, 10, 8)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -71,11 +57,6 @@ func (m *Machine) setID() error {
|
|||||||
func (m *Machine) scan(opts *ScanOptions) error {
|
func (m *Machine) scan(opts *ScanOptions) error {
|
||||||
for i := 0; i < RingsCount; i++ {
|
for i := 0; i < RingsCount; i++ {
|
||||||
if err := m.tryApplyWireguardConfig(i); err != nil {
|
if err := m.tryApplyWireguardConfig(i); err != nil {
|
||||||
m.error(err).
|
|
||||||
WithField("subsystem", "wireguard").
|
|
||||||
WithField("node", m.Name).
|
|
||||||
WithField("ring", i).
|
|
||||||
Print()
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-26
@@ -5,12 +5,10 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"darvaza.org/resolver"
|
"darvaza.org/resolver"
|
||||||
"darvaza.org/slog"
|
|
||||||
"darvaza.org/slog/handlers/discard"
|
|
||||||
"github.com/hack-pad/hackpadfs/os"
|
"github.com/hack-pad/hackpadfs/os"
|
||||||
)
|
)
|
||||||
|
|
||||||
// A ScanOption pre-configures the Zones before scanning
|
// A ScanOption preconfigures the Zones before scanning
|
||||||
type ScanOption func(*Zones, *ScanOptions) error
|
type ScanOption func(*Zones, *ScanOptions) error
|
||||||
|
|
||||||
// ScanOptions contains flags used by the initial scan
|
// ScanOptions contains flags used by the initial scan
|
||||||
@@ -19,10 +17,6 @@ type ScanOptions struct {
|
|||||||
// pre-populate Machine.PublicAddresses during the
|
// pre-populate Machine.PublicAddresses during the
|
||||||
// initial scan
|
// initial scan
|
||||||
DontResolvePublicAddresses bool
|
DontResolvePublicAddresses bool
|
||||||
|
|
||||||
// Logger specifies the logger to be used. otherwise
|
|
||||||
// the scanner will be mute
|
|
||||||
slog.Logger
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ResolvePublicAddresses instructs the scanner to use
|
// ResolvePublicAddresses instructs the scanner to use
|
||||||
@@ -61,19 +55,6 @@ func WithResolver(h resolver.Resolver) ScanOption {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// WithLogger specifies what to use for logging
|
|
||||||
func WithLogger(log slog.Logger) ScanOption {
|
|
||||||
return func(m *Zones, opt *ScanOptions) error {
|
|
||||||
if log == nil {
|
|
||||||
log = discard.New()
|
|
||||||
}
|
|
||||||
|
|
||||||
opt.Logger = log
|
|
||||||
m.log = log
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *Zones) setDefaults(opt *ScanOptions) error {
|
func (m *Zones) setDefaults(opt *ScanOptions) error {
|
||||||
if m.resolver == nil {
|
if m.resolver == nil {
|
||||||
h := resolver.NewCloudflareLookuper()
|
h := resolver.NewCloudflareLookuper()
|
||||||
@@ -83,12 +64,6 @@ func (m *Zones) setDefaults(opt *ScanOptions) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if opt.Logger == nil {
|
|
||||||
if err := WithLogger(nil)(m, opt); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+26
-42
@@ -2,9 +2,9 @@ package zones
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"io/fs"
|
"io/fs"
|
||||||
|
"log"
|
||||||
|
"os"
|
||||||
"sort"
|
"sort"
|
||||||
|
|
||||||
"darvaza.org/core"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func (m *Zones) scan(opts *ScanOptions) error {
|
func (m *Zones) scan(opts *ScanOptions) error {
|
||||||
@@ -33,40 +33,22 @@ func (m *Zones) scanDirectory(_ *ScanOptions) error {
|
|||||||
|
|
||||||
for _, e := range entries {
|
for _, e := range entries {
|
||||||
if e.IsDir() {
|
if e.IsDir() {
|
||||||
z, err := m.newZone(e.Name())
|
z := &Zone{
|
||||||
switch {
|
zones: m,
|
||||||
case err != nil:
|
Name: e.Name(),
|
||||||
return core.Wrap(err, e.Name())
|
|
||||||
case z.Machines.Len() == 0:
|
|
||||||
z.warn(nil).
|
|
||||||
WithField("zone", z.Name).
|
|
||||||
Print("empty")
|
|
||||||
default:
|
|
||||||
m.Zones = append(m.Zones, z)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err := z.scan(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
m.Zones = append(m.Zones, z)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Zones) newZone(name string) (*Zone, error) {
|
|
||||||
z := &Zone{
|
|
||||||
zones: m,
|
|
||||||
logger: m,
|
|
||||||
Name: name,
|
|
||||||
}
|
|
||||||
|
|
||||||
z.debug().
|
|
||||||
WithField("zone", z.Name).
|
|
||||||
Print("found")
|
|
||||||
|
|
||||||
if err := z.scan(); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return z, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *Zones) scanMachines(opts *ScanOptions) error {
|
func (m *Zones) scanMachines(opts *ScanOptions) error {
|
||||||
var err error
|
var err error
|
||||||
m.ForEachMachine(func(p *Machine) bool {
|
m.ForEachMachine(func(p *Machine) bool {
|
||||||
@@ -142,6 +124,19 @@ func (m *Zones) scanGateways(_ *ScanOptions) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *Zones) scanCephMonitors(_ *ScanOptions) error {
|
||||||
|
cfg, err := m.GetCephConfig()
|
||||||
|
switch {
|
||||||
|
case os.IsNotExist(err):
|
||||||
|
err = nil
|
||||||
|
case err != nil:
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Print(cfg)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (z *Zone) scan() error {
|
func (z *Zone) scan() error {
|
||||||
// each directory is a machine
|
// each directory is a machine
|
||||||
entries, err := fs.ReadDir(z.zones.dir, z.Name)
|
entries, err := fs.ReadDir(z.zones.dir, z.Name)
|
||||||
@@ -152,22 +147,11 @@ func (z *Zone) scan() error {
|
|||||||
for _, e := range entries {
|
for _, e := range entries {
|
||||||
if e.IsDir() {
|
if e.IsDir() {
|
||||||
m := &Machine{
|
m := &Machine{
|
||||||
zone: z,
|
zone: z,
|
||||||
logger: z,
|
Name: e.Name(),
|
||||||
Name: e.Name(),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m.debug().
|
|
||||||
WithField("node", m.Name).
|
|
||||||
WithField("zone", z.Name).
|
|
||||||
Print("found")
|
|
||||||
|
|
||||||
if err := m.init(); err != nil {
|
if err := m.init(); err != nil {
|
||||||
m.error(err).
|
|
||||||
WithField("node", m.Name).
|
|
||||||
WithField("zone", z.Name).
|
|
||||||
Print()
|
|
||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ package zones
|
|||||||
func (m *Zones) SyncAll() error {
|
func (m *Zones) SyncAll() error {
|
||||||
for _, fn := range []func() error{
|
for _, fn := range []func() error{
|
||||||
m.SyncAllWireguard,
|
m.SyncAllWireguard,
|
||||||
m.SyncAllCeph,
|
|
||||||
} {
|
} {
|
||||||
if err := fn(); err != nil {
|
if err := fn(); err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -32,13 +31,3 @@ func (m *Zones) SyncAllWireguard() error {
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// SyncAllCeph updates the ceph.conf file
|
|
||||||
func (m *Zones) SyncAllCeph() error {
|
|
||||||
cfg, err := m.GenCephConfig()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return m.WriteCephConfig(cfg)
|
|
||||||
}
|
|
||||||
|
|||||||
+1
-11
@@ -6,8 +6,6 @@ import (
|
|||||||
"sort"
|
"sort"
|
||||||
|
|
||||||
"darvaza.org/resolver"
|
"darvaza.org/resolver"
|
||||||
"darvaza.org/slog"
|
|
||||||
"github.com/gofrs/uuid/v5"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -87,8 +85,7 @@ 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:"-"`
|
|
||||||
|
|
||||||
ID int `toml:"id"`
|
ID int `toml:"id"`
|
||||||
Name string `toml:"name"`
|
Name string `toml:"name"`
|
||||||
@@ -138,22 +135,15 @@ func (z *Zone) GatewayIDs() ([]int, int) {
|
|||||||
return out, len(out)
|
return out, len(out)
|
||||||
}
|
}
|
||||||
|
|
||||||
// revive:disable:line-length-limit
|
|
||||||
|
|
||||||
// Zones represents all zones in a cluster
|
// Zones represents all zones in a cluster
|
||||||
type Zones struct {
|
type Zones struct {
|
||||||
dir fs.FS
|
dir fs.FS
|
||||||
log slog.Logger
|
|
||||||
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"`
|
|
||||||
|
|
||||||
Zones []*Zone `toml:"zones"`
|
Zones []*Zone `toml:"zones"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// revive:enable:line-length-limit
|
|
||||||
|
|
||||||
// ForEachMachine calls a function for each Machine in the cluster
|
// ForEachMachine calls a function for each Machine in the cluster
|
||||||
// until instructed to terminate the loop
|
// until instructed to terminate the loop
|
||||||
func (m *Zones) ForEachMachine(fn func(*Machine) bool) {
|
func (m *Zones) ForEachMachine(fn func(*Machine) bool) {
|
||||||
|
|||||||
Reference in New Issue
Block a user