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 <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2023-06-19 21:43:43 +02:00
parent ddd96e5cb9
commit ad9ef5e7fb
2 changed files with 7 additions and 1 deletions

View File

@ -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 {

View File

@ -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";