]> git.proxmox.com Git - proxmox-acme.git/blobdiff - src/PVE/ACME/DNSChallenge.pm
dns: cope with plugin json index not being available
[proxmox-acme.git] / 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 $plugins = from_json(PVE::Tools::file_get_contents($DNS_API_CHALLENGE_SCHEMA_FN));
 
+my $plugin_cache;
 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 {
+    my $plugins = get_supported_plugins();
     return {
        api => {
            description => "API plugin name",