From 0d1cf9b88f4cb13a43d8e4c44e1dd2e278503994 Mon Sep 17 00:00:00 2001 From: Dean Hamstead Date: Thu, 8 Sep 2022 22:44:23 -0700 Subject: [PATCH] Example fix for GH#1549 --- lib/Rex/Virtualization.pm | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/lib/Rex/Virtualization.pm b/lib/Rex/Virtualization.pm index e5e67d74f..089108263 100644 --- a/lib/Rex/Virtualization.pm +++ b/lib/Rex/Virtualization.pm @@ -19,17 +19,28 @@ my %VM_PROVIDER; Rex::Config->register_config_handler( virtualization => sub { - my ($param) = @_; + my ($params) = @_; - if ( ref($param) eq '' ) { + if ( ref($params) eq '' ) { #support 'set virtualization => 'LibVirt', but leave the way open for using a hash in future #other virtualisation drivers may need more settings... - $param = { type => $param }; + $params = { type => $params }; } - if ( exists $param->{type} ) { - Rex::Config->set( virtualization => $param->{type} ); + if ( ref($params) eq 'HASH' ) { + + if ( exists $params->{type} ) { + Rex::Config->set( virtualization => $params ); + } + else { + # Probably do some error thing here + } + } + else { + # Some error thing here so people dont go: + # set virtualzation => [qw/what is this anyway/'] + } } );