]> git.proxmox.com Git - proxmox-acme.git/commitdiff
dns: cope with plugin json index not being available
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 9 Nov 2021 16:57:57 +0000 (17:57 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 9 Nov 2021 17:03:40 +0000 (18:03 +0100)
not nice to die plainly on a using this module (which can come in
indirectly/transitively), so lets better cope with that.

Nice side-effect, if nothing uses it, it won't get loaded, so less
IO and memory in that case.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
src/PVE/ACME/DNSChallenge.pm

index 9b2897001145c070f5e34a5e56295dfe4a5b32d8..7214d8889ecadee1c8b9b1a0c58e2ed127d5e679 100644 (file)
@@ -23,13 +23,19 @@ sub type {
 }
 
 my $DNS_API_CHALLENGE_SCHEMA_FN = '/usr/share/proxmox-acme/dns-challenge-schema.json';
 }
 
 my $DNS_API_CHALLENGE_SCHEMA_FN = '/usr/share/proxmox-acme/dns-challenge-schema.json';
-my $plugins = from_json(PVE::Tools::file_get_contents($DNS_API_CHALLENGE_SCHEMA_FN));
 
 
+my $plugin_cache;
 sub get_supported_plugins {
 sub get_supported_plugins {
-    return $plugins;
+    if (!$plugin_cache) {
+       $plugin_cache = -e $DNS_API_CHALLENGE_SCHEMA_FN # we allow this to be optional as not all users require
+           ? from_json(PVE::Tools::file_get_contents($DNS_API_CHALLENGE_SCHEMA_FN))
+           : {};
+    }
+    return $plugin_cache;
 }
 
 sub properties {
 }
 
 sub properties {
+    my $plugins = get_supported_plugins();
     return {
        api => {
            description => "API plugin name",
     return {
        api => {
            description => "API plugin name",