zones.override automatically added to domainlist
authorheiko
Wed, 07 Jan 2015 17:14:18 +0100
changeset 18 e21e904c1320
parent 16 6d401297850b
child 19 3ea8010e4fbc
zones.override automatically added to domainlist If the local: domainlist is used, the domains containted in the override file are added automatically to the list of domains
plugins/check_dns-delegation
t/10-minimal.t
--- a/plugins/check_dns-delegation	Wed Jan 07 15:56:05 2015 +0100
+++ b/plugins/check_dns-delegation	Wed Jan 07 17:14:18 2015 +0100
@@ -47,6 +47,8 @@
 master/slave zones. The 127.in-addr.arpa, 168.192.in-addr.arpa, and
 0.in-addr.arpa, and 127.in-addr.arpa zones are suppressed.
 
+The B<override> domains are added automatically (See opt B<override>).
+
 =back
 
 =cut
@@ -100,7 +102,8 @@
 }
 
 sub get_domains {
-    my @sources = @_;
+    my %arg = @_;
+    my @sources = @{ $arg{sources} };
     my @domains = ();
 
     foreach my $src (@sources) {
@@ -113,6 +116,7 @@
 
         if ($src =~ m{^local:}) {
             push @domains, get_local_zones;
+            push @domains, @{$arg{local}} if $arg{local};
             next;
         }
 
@@ -235,11 +239,11 @@
       )
       and @argv
       or pod2usage;
-    my @domains = get_domains(@argv);
     my %override = read_override($opt_override) if defined $opt_override;
+    my @domains = get_domains(sources => \@argv, local => [keys %override]);
 
     my (@OK, %CRITICAL);
-    foreach my $domain (shuffle @domains, keys %override) {
+    foreach my $domain (shuffle @domains) {
         print STDERR "$domain " if $opt_progress;
 
         my @ns = eval { ns_ok($domain, $opt_reference, \%override) };
--- a/t/10-minimal.t	Wed Jan 07 15:56:05 2015 +0100
+++ b/t/10-minimal.t	Wed Jan 07 17:14:18 2015 +0100
@@ -34,10 +34,9 @@
 
     # get_domains should read a list of names, either from a file
     # or from the arguments, or from a combination of both
-    is_deeply [get_domains(qw(a b c))], [qw(a b c)] => 'domains from list';
-    is_deeply [get_domains("$tmp")],    [qw(a b c d)] => 'domains from file';
-    is_deeply [get_domains('a', "$tmp", 'z')],
-      [qw(a a b c d z)] => 'domains from args and file';
+    is_deeply [get_domains(sources => [qw/a b c/])], [qw(a b c)] => 'domains from list';
+    is_deeply [get_domains(sources => ["$tmp"])],    [qw(a b c d)] => 'domains from file';
+    is_deeply [get_domains(sources => ['a', "$tmp", 'z'])], [qw(a a b c d z)] => 'domains from args and file';
 
     is_deeply {read_override("$tmp")}, { c => ['ns1', 'ns2'] }, 'override file';