Resiliency to nil options

This commit is contained in:
Joel Elkins 2023-12-17 12:49:22 -06:00
parent 8449c17c23
commit a2748ad1d5
No known key found for this signature in database
GPG Key ID: 133589DC38921AE2
2 changed files with 11 additions and 1 deletions

View File

@ -162,8 +162,15 @@ func Init(conn context.Context) error {
return err
}
Containers, Networks, Options = p.Containers, p.Networks, p.Options
var dom, dns, tsn, tsk string
if Options != nil {
dom = Options.DomainName
dns = Options.DNSServer
tsn = Options.TSIGName
tsk = Options.TSIGKey
}
for i := range Containers {
Containers[i].Init(conn, Networks, Options.DomainName, Options.DNSServer, Options.TSIGName, Options.TSIGKey)
Containers[i].Init(conn, Networks, dom, dns, tsn, tsk)
}
slices.SortFunc(Containers, func(a, b *container.Container) bool {
return a.Name < b.Name

View File

@ -47,6 +47,9 @@ func (c *Container) doReverse(rv string, dn string) error {
}
func (c *Container) NsUpdateCommands() cmd.Set {
if c.DomainName == "" || c.DnsServer == "" {
return cmd.Set{ID: "NSUPDATE_NOT_CONFIGURED"}
}
hostname := c.Hostname
if c.Hostname == "" {
hostname = c.Name