diff --git a/commands/getZones.go b/commands/getZones.go index 865056e59..f4f7c13ee 100644 --- a/commands/getZones.go +++ b/commands/getZones.go @@ -209,10 +209,18 @@ func GetZone(args GetZoneArgs) error { // Write the heading: + dspVariableName := "DSP_" + strings.ToUpper(args.CredName) + if args.OutputFormat == "js" || args.OutputFormat == "djs" { - fmt.Fprintf(w, `var %s = NewDnsProvider("%s", "%s");`+"\n", - args.CredName, args.CredName, args.ProviderName) - fmt.Fprintf(w, `var REG_CHANGEME = NewRegistrar("ThirdParty", "NONE");`+"\n") + + if args.ProviderName == "-" { + fmt.Fprintf(w, `var %s = NewDnsProvider("%s");`+"\n", + dspVariableName, args.CredName) + } else { + fmt.Fprintf(w, `var %s = NewDnsProvider("%s", "%s");`+"\n", + dspVariableName, args.CredName, args.ProviderName) + } + fmt.Fprintf(w, `var REG_CHANGEME = NewRegistrar("none");`+"\n") } // print each zone @@ -234,7 +242,7 @@ func GetZone(args GetZoneArgs) error { } fmt.Fprintf(w, `D("%s", REG_CHANGEME%s`, zoneName, sep) var o []string - o = append(o, fmt.Sprintf("DnsProvider(%s)", args.CredName)) + o = append(o, fmt.Sprintf("DnsProvider(%s)", dspVariableName)) defaultTTL := uint32(args.DefaultTTL) if defaultTTL == 0 { defaultTTL = prettyzone.MostCommonTTL(recs) diff --git a/commands/test_data/example.org.zone.js b/commands/test_data/example.org.zone.js index d26e65587..65b5561c9 100644 --- a/commands/test_data/example.org.zone.js +++ b/commands/test_data/example.org.zone.js @@ -1,7 +1,7 @@ -var bind = NewDnsProvider("bind", "BIND"); -var REG_CHANGEME = NewRegistrar("ThirdParty", "NONE"); +var DSP_BIND = NewDnsProvider("bind", "BIND"); +var REG_CHANGEME = NewRegistrar("none"); D("example.org", REG_CHANGEME, - DnsProvider(bind), + DnsProvider(DSP_BIND), DefaultTTL(7200), //SOA('@', 'ns1.example.org.', 'hostmaster.example.org.', 2020030700, 7200, 3600, 864000, 7200, TTL(43200)), //NAMESERVER('ns1.example.org.'), diff --git a/commands/test_data/simple.com.zone.js b/commands/test_data/simple.com.zone.js index 0c7ede78b..89682f7e7 100644 --- a/commands/test_data/simple.com.zone.js +++ b/commands/test_data/simple.com.zone.js @@ -1,7 +1,7 @@ -var bind = NewDnsProvider("bind", "BIND"); -var REG_CHANGEME = NewRegistrar("ThirdParty", "NONE"); +var DSP_BIND = NewDnsProvider("bind", "BIND"); +var REG_CHANGEME = NewRegistrar("none"); D("simple.com", REG_CHANGEME, - DnsProvider(bind), + DnsProvider(DSP_BIND), //SOA('@', 'ns3.serverfault.com.', 'sysadmin.stackoverflow.com.', 2020022300, 3600, 600, 604800, 1440), //NAMESERVER('ns-1313.awsdns-36.org.'), //NAMESERVER('ns-736.awsdns-28.net.'),