Compare commits

..

10 Commits

Author SHA1 Message Date
amery 8d1b9c4f04 WIP
Signed-off-by: Alejandro Mery <amery@jpi.io>
2023-09-12 12:49:14 +00:00
amery 60d3a5f650 dns: introduce AddrRecord{} to abstract A/AAAA entries
Signed-off-by: Alejandro Mery <amery@jpi.io>
2023-09-12 12:49:14 +00:00
amery 67e27b7f01 vscode: add Lookuper, publicsuffix and libdns to the dictionary
Signed-off-by: Alejandro Mery <amery@jpi.io>
2023-09-12 12:49:14 +00:00
amery 03dfc73f63 build-sys: use local asciigoat.org/ini
Signed-off-by: Alejandro Mery <amery@jpi.io>
2023-09-12 12:49:02 +00:00
amery 41e2b75964 Merge branch 'pr-amery-cluster' into next-amery 2023-09-12 12:48:55 +00:00
amery 6e7f24f491 cluster: ensure ceph monitors are set when loading a config file
Signed-off-by: Alejandro Mery <amery@jpi.io>
2023-09-12 12:47:24 +00:00
amery 54b302c6d5 vscode: add asciigoat, cyclomatic and Wrapf to the dictionary
Signed-off-by: Alejandro Mery <amery@jpi.io>
2023-09-12 12:47:18 +00:00
amery fb331b6586 Merge branch 'pr-amery-wireguard-ini' into next-amery 2023-09-12 12:46:17 +00:00
amery f62a47003d Merge pull request 'cluster: introduce Regions to group zones' (#22)
Reviewed-on: #22
2023-09-12 14:45:01 +02:00
amery 5abaed9047 Merge pull request 'jpictl: fix verbosity handling' (#21)
Reviewed-on: #21
2023-09-12 14:43:40 +02:00
+75
View File
@@ -0,0 +1,75 @@
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)
}