Compare commits

..

9 Commits

Author SHA1 Message Date
amery 314510cafb WIP
Signed-off-by: Alejandro Mery <amery@jpi.io>
2023-09-12 04:37:51 +00:00
amery d99bbc3add dns: introduce AddrRecord{} to abstract A/AAAA entries
Signed-off-by: Alejandro Mery <amery@jpi.io>
2023-09-12 02:25:07 +00:00
amery bead6184f5 vscode: add Lookuper, publicsuffix and libdns to the dictionary
Signed-off-by: Alejandro Mery <amery@jpi.io>
2023-09-12 02:25:07 +00:00
amery b267bdfe5f cluster: ensure ceph monitors are set when loading a config file
Signed-off-by: Alejandro Mery <amery@jpi.io>
2023-09-12 02:25:07 +00:00
amery 8b07a8e8fd build-sys: use local asciigoat.org/ini
Signed-off-by: Alejandro Mery <amery@jpi.io>
2023-09-12 02:22:40 +00:00
amery 58e3a64fe7 vscode: add asciigoat, cyclomatic and Wrapf to the dictionary
Signed-off-by: Alejandro Mery <amery@jpi.io>
2023-09-12 02:22:40 +00:00
amery f2e6137ae5 Merge branch 'pr-amery-regions' into next-amery 2023-09-12 02:21:47 +00:00
amery fd45b39062 Merge branch 'pr-amery-verbosity' into next-amery 2023-09-12 01:40:14 +00:00
amery 12f3d8e26f Merge branch 'pr-amery-wireguard-ini' into next-amery 2023-09-11 21:45:48 +00:00
-75
View File
@@ -1,75 +0,0 @@
package main
import (
"context"
"os"
"github.com/spf13/cobra"
"git.jpi.io/amery/jpictl/pkg/cluster"
"git.jpi.io/amery/jpictl/pkg/dns"
)
func newDNSManager(m *cluster.Cluster) (*dns.Manager, error) {
domain := m.Domain
if m.Name != "" {
domain = m.Name + "." + domain
}
mgr, err := dns.NewManager(dns.WithDomain(domain), dns.WithLogger(log))
if err != nil {
return nil, err
}
m.ForEachZone(func(z *cluster.Zone) bool {
z.ForEachMachine(func(p *cluster.Machine) bool {
err = mgr.AddHost(context.TODO(), z.Name, p.ID, true, p.PublicAddresses...)
return err != nil
})
return err != nil
})
if err != nil {
return nil, err
}
for _, r := range m.Regions {
err := mgr.AddRegion(context.TODO(), r.Name, r.Zones()...)
if err != nil {
return nil, err
}
}
return mgr, nil
}
// Command
var dnsCmd = &cobra.Command{
Use: "dns",
}
var dnsWriteCmd = &cobra.Command{
Use: "write",
PreRun: setVerbosity,
RunE: func(_ *cobra.Command, _ []string) error {
m, err := cfg.LoadZones(true)
if err != nil {
return err
}
mgr, err := newDNSManager(m)
if err != nil {
return err
}
_, err = mgr.WriteTo(os.Stdout)
return err
},
}
func init() {
rootCmd.AddCommand(dnsCmd)
dnsCmd.AddCommand(dnsWriteCmd)
}