Nix::getHydraNotifyPrometheusConfig: print errors if the configuration provided is invalid.

This commit is contained in:
Your Name 2021-08-24 11:35:38 -04:00
parent 4ebdcc290e
commit 24467a7bde

View file

@ -74,12 +74,22 @@ sub getHydraNotifyPrometheusConfig {
my ($config) = @_;
my $cfg = $config->{hydra_notify};
if (!defined($cfg) || ref $cfg ne "HASH") {
if (!defined($cfg)) {
return undef;
}
if (ref $cfg ne "HASH") {
print STDERR "Error reading Hydra's configuration file: hydra_notify should be a block.\n";
return undef;
}
my $cfg = $cfg->{prometheus};
if (!defined($cfg) || ref $cfg ne "HASH") {
if (!defined($cfg)) {
return undef;
}
if (ref $cfg ne "HASH") {
print STDERR "Error reading Hydra's configuration file: hydra_notify.prometheus should be a block.\n";
return undef;
}
@ -88,6 +98,9 @@ sub getHydraNotifyPrometheusConfig {
"listen_address" => $cfg->{'listen_address'},
"port" => $cfg->{'port'},
};
} else {
print STDERR "Error reading Hydra's configuration file: hydra_notify.prometheus should include listen_address and port.\n";
return undef;
}
return undef;