Skip to content
Snippets Groups Projects
Commit 2aead4db authored by Andreas Romeyke's avatar Andreas Romeyke
Browse files

- removed validate_global()

- added common_global_validate() as a replacement
parent 5d087059
No related branches found
No related tags found
No related merge requests found
...@@ -49,30 +49,21 @@ BEGIN { ...@@ -49,30 +49,21 @@ BEGIN {
} }
} }
sub validate_global { sub common_global_validate {
my ($self, $opt, $args) = @_; my ($self, $opt, $args) = @_;
my $app = $self->app; foreach my $override (qw(elasticsearch_host elasticsearch_port http_only)) {
my $global = $app->global_options;
foreach my $global_option (keys %{$global}) {
if ( if (
exists $opt->{$global_option} (exists $opt->{$override})
and $opt->{$global_option} ne $global->{$global_option} and ($config{$override} ne $opt->{$override})
) { ) {
say STDERR <<"HINT"; say STDERR <<"HINT";
Hint: override local option Hint: override local config with:
$global_option => $opt->{$global_option} $override => $opt->{$override} (config: $config{$override})
with global option
$global_option => $global->{$global_option}
HINT HINT
$config{$override} = $opt->{$override};
} }
$opt->{$global_option} = $global->{$global_option};
} }
# option overrides config # 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'; $config{elasticsearch_protocol} = $config{http_only} ? 'http' : 'https';
return 1; return 1;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment