fix: dont assume ipv4 exists

This commit is contained in:
decentral1se 2022-01-01 21:34:49 +01:00
parent 35d95fb9fb
commit 810bc27967
Signed by: decentral1se
GPG Key ID: 03789458B3D0C410
1 changed files with 14 additions and 8 deletions

View File

@ -72,10 +72,21 @@ You may also invoke this command in "wizard" mode and be prompted for input
}
if internal.AutoDNSRecord {
logrus.Infof("automatically configuring @./*. A records for %s (--auto)", zone)
if err := autoConfigure(c, &provider, zone); err != nil {
ipv4, err := dns.EnsureIPv4(zone)
if err != nil {
logrus.Debugf("no ipv4 associated with %s, prompting for input", zone)
if err := internal.EnsureDNSValueFlag(c); err != nil {
logrus.Fatal(err)
}
ipv4 = internal.DNSValue
}
logrus.Infof("automatically configuring @./*. A records for %s for %s (--auto)", zone, ipv4)
if err := autoConfigure(c, &provider, zone, ipv4); err != nil {
logrus.Fatal(err)
}
return nil
}
@ -159,12 +170,7 @@ You may also invoke this command in "wizard" mode and be prompted for input
},
}
func autoConfigure(c *cli.Context, provider *gandi.Provider, zone string) error {
ipv4, err := dns.EnsureIPv4(zone)
if err != nil {
return err
}
func autoConfigure(c *cli.Context, provider *gandi.Provider, zone, ipv4 string) error {
ttl, err := dns.GetTTL(internal.DNSTTL)
if err != nil {
return err