From 2aead4db1a6b3cc05ceac42fab9dd35c4f405396 Mon Sep 17 00:00:00 2001 From: Andreas Romeyke <andreas.romeyke@slub-dresden.de> Date: Tue, 28 May 2024 13:48:38 +0200 Subject: [PATCH] - removed validate_global() - added common_global_validate() as a replacement --- lib/SLUB/LZA/TA.pm | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/lib/SLUB/LZA/TA.pm b/lib/SLUB/LZA/TA.pm index 8025854..5306640 100644 --- a/lib/SLUB/LZA/TA.pm +++ b/lib/SLUB/LZA/TA.pm @@ -49,30 +49,21 @@ BEGIN { } } -sub validate_global { +sub common_global_validate { my ($self, $opt, $args) = @_; - my $app = $self->app; - my $global = $app->global_options; - foreach my $global_option (keys %{$global}) { + foreach my $override (qw(elasticsearch_host elasticsearch_port http_only)) { if ( - exists $opt->{$global_option} - and $opt->{$global_option} ne $global->{$global_option} + (exists $opt->{$override}) + and ($config{$override} ne $opt->{$override}) ) { say STDERR <<"HINT"; -Hint: override local option - $global_option => $opt->{$global_option} - with global option - $global_option => $global->{$global_option} - +Hint: override local config with: + $override => $opt->{$override} (config: $config{$override}) HINT - + $config{$override} = $opt->{$override}; } - $opt->{$global_option} = $global->{$global_option}; } # option overrides config - $config{elasticsearch_host} = $global->{elasticsearch_host} if (exists $global->{elasticsearch_host}); - $config{elasticsearch_port} = $global->{elasticsearch_port} if (exists $global->{elasticsearch_port}); - $config{http_only} = $global->{http_only} if (exists $global->{http_only}); $config{elasticsearch_protocol} = $config{http_only} ? 'http' : 'https'; return 1; } -- GitLab