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

- add validate_global() to validate global options and set overrides

- added common global_opt_spec()
parent ccce753d
No related branches found
No related tags found
No related merge requests found
......@@ -39,7 +39,7 @@ BEGIN {
$config_ref->{decrypted_password} = SLUB::LZA::TA::Crypt::decrypt($config_ref->{password});
}
%config = %{$config_ref};
$config{elasticsearchprotocol} = $config{httponly} ? 'http' : 'https';
$config{elasticsearch_protocol} = $config{http_only} ? 'http' : 'https';
}
$cache_path = $home->child('.cache')->child('ta-tool.cache');
if ($cache_path->is_file and -s $cache_path < 8192 * 1024) { # if size > 8MB, write new at end, see END{}-block
......@@ -47,7 +47,45 @@ BEGIN {
%cache = %{$cache_ref};
}
}
}
sub validate_global {
my ($self, $opt, $args) = @_;
my $app = $self->app;
my $global = $app->global_options;
foreach my $global_option (keys %{$global}) {
if (
exists $opt->{$global_option}
and $opt->{$global_option} ne $global->{$global_option}
) {
say STDERR <<"HINT";
Hint: override local option
$global_option => $opt->{$global_option}
with global option
$global_option => $global->{$global_option}
HINT
}
$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;
}
sub global_opt_spec {
return (
[ "debug|D" => "enable user agent debug output" ],
[ "verbose|v" => "enable verbose output" ],
[ "elasticsearch-host|e=s" => "host adress where Archivematica's ElasticSearch runs, overrides config value (command 'init')" ],
[ "elasticsearch-port|E=s" => "port of Archivematica's ElasticSearch, overrides config value (command 'init')", {default => 9200} ],
[ "http-only" => "use HTTP instead HTTPS, overrides config value (command 'init')"],
[ "logdir|l=s" => "logdir where Archivematica stores it server log files (required)"],
);
}
END {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment