From ad9ef5e7fb0e5436bf4435f220e30c2aa6e67dcc Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Mon, 19 Jun 2023 21:43:43 +0200 Subject: [PATCH] iso env: add singleton getter this is basically global state, so don't bend overt backwards in passing it around, just access it wherever.. Signed-off-by: Thomas Lamprecht --- Proxmox/Install/ISOEnv.pm | 6 ++++++ proxinstall | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Proxmox/Install/ISOEnv.pm b/Proxmox/Install/ISOEnv.pm index faca026..514dc30 100644 --- a/Proxmox/Install/ISOEnv.pm +++ b/Proxmox/Install/ISOEnv.pm @@ -147,6 +147,12 @@ sub setup { return $env; } +my $_env = undef; +sub get { + $_env = setup() if !defined($_env); + return $_env; +} + my $test_images; # sets a test image to use as disk and enables the testmode sub set_test_image { diff --git a/proxinstall b/proxinstall index 04845e8..08dd7e9 100755 --- a/proxinstall +++ b/proxinstall @@ -40,7 +40,7 @@ if (!$ENV{G_SLICE} || $ENV{G_SLICE} ne "always-malloc") { Proxmox::Install::ISOEnv::set_test_image($test_image) if $test_image; } -my $iso_env = Proxmox::Install::ISOEnv::setup(); +my $iso_env = Proxmox::Install::ISOEnv::get(); # init singleton my $run_env = Proxmox::Install::RunEnv::query_installation_environment(); my $zfstestpool = "test_rpool"; -- 2.39.5