From 3d5c749696a7fc49cb23af067f2fe259516d0bc4 Mon Sep 17 00:00:00 2001 From: Andrii Nikitin Date: Mon, 29 Sep 2025 09:32:46 +0200 Subject: [PATCH] Load mojo plugin from env variables --- lib/MirrorCache/WebAPI.pm | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/MirrorCache/WebAPI.pm b/lib/MirrorCache/WebAPI.pm index 3d9ae1d1..801396c8 100644 --- a/lib/MirrorCache/WebAPI.pm +++ b/lib/MirrorCache/WebAPI.pm @@ -1,4 +1,4 @@ -# Copyright (C) 2020 SUSE LLC +# Copyright (C) 2020-2025 SUSE LLC # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -143,6 +143,16 @@ sub startup { $self->plugin('RootRemote'); } } + # Load Plugins from ENV + foreach (sort keys %ENV) { + my (undef, $plug) = split /MIRRORCACHE_PLUGIN_(.*)/, $_; + next unless $plug; + my $err = 1; + eval { $self->plugin($plug); $err = 0 }; + if ($err) { + warn("Could not load plugin from {$plug}: $@\n") + } + } } sub _setup_webui {