]> git.proxmox.com Git - proxmox-acme.git/blobdiff - src/test/verify-dnsapi-plugins-in-schema.pl
tests: make missing-plugin also output makefile proposals
[proxmox-acme.git] / src / test / verify-dnsapi-plugins-in-schema.pl
index a9628612bd67951080628b734bca7dfd146ea44b..bf4b4a86276f613bd299f70c4d143c019d8591e8 100755 (executable)
@@ -22,28 +22,36 @@ dir_glob_foreach($dnsapi_path, qr/dns_(\S+)\.sh/, sub {
 my $DNS_API_CHALLENGE_SCHEMA_FN = '../dns-challenge-schema.json';
 my $defined_plugins = from_json(PVE::Tools::file_get_contents($DNS_API_CHALLENGE_SCHEMA_FN));
 
+my ($missing_json_proposal, $missing_makefile_proposal) = ('', '');
+
 my $ok = 1;
 # first check for missing ones, delete from hash so we can easily see if a plug got removed/renamed
-my $printed_missing = 0;
 for my $provider (sort @$acmesh_plugins) {
     my $schema = delete $defined_plugins->{$provider};
     if (!defined($schema)) {
-       print STDERR "missing (also adapt makefile!):\n" if !$printed_missing;
-       print STDERR "    '$provider' => {},\n";
-       $printed_missing = 1;
+       $missing_json_proposal .= "    \"$provider\": {},\n";
+       $missing_makefile_proposal .= "\tdnsapi/dns_${provider}.sh \\\n";
        $ok = 0;
     }
 }
 
+if (!$ok) {
+    print STDERR "\nmissing plugins, add the following to the JSON schema:\n";
+    print STDERR $missing_json_proposal;
+
+    print STDERR "\nand to the Makefile:\n";
+    print STDERR $missing_makefile_proposal;
+}
+
 my $printed_extra = 0;
 for my $provider (sort keys %$defined_plugins) {
-    print STDERR "extra:\n" if !$printed_extra;
+    print STDERR "\nplugins that got removed or renamed upstream:\n" if !$printed_extra;
     print STDERR "    $provider\n";
     $printed_extra = 1;
     $ok = 0;
 }
 
-die "schema not in sync with available plugins!\n" if !$ok;
+die "\nERROR: schema not in sync with available plugins!\n\n" if !$ok;
 
 print STDERR "OK: DNS challenge schema in sync with available plugins.\n";
 exit(0);