From 4f95774ca38f23cf8e0e3cb6bfcc2da2ab7463d1 Mon Sep 17 00:00:00 2001 From: Shay Bergmann Date: Mon, 26 Jul 2021 03:43:09 +0000 Subject: [PATCH] Factor out common options --- src/lib/Hydra.pm | 11 ++--------- src/lib/Hydra/Config.pm | 11 +++++++++++ src/lib/Hydra/Helper/Nix.pm | 5 ++--- 3 files changed, 15 insertions(+), 12 deletions(-) create mode 100644 src/lib/Hydra/Config.pm diff --git a/src/lib/Hydra.pm b/src/lib/Hydra.pm index 6ba1b663..3ce87bb5 100644 --- a/src/lib/Hydra.pm +++ b/src/lib/Hydra.pm @@ -6,6 +6,7 @@ use parent 'Catalyst'; use Moose; use Hydra::Plugin; use Hydra::Model::DB; +use Hydra::Config; use Catalyst::Runtime '5.70'; use Catalyst qw/ConfigLoader Unicode::Encoding @@ -50,15 +51,7 @@ __PACKAGE__->config( }, 'Plugin::ConfigLoader' => { driver => { - 'General' => { - # Please keep these options in sync with corresponding - # call to `new Config::General` in `getHydraConfig()` sub - # in `Hydra/Helper/Nix.pm`. This is necessary in order to - # maintain consistent interpretation of the config by the - # various hydra components. - -UseApacheInclude => 1, - -IncludeAgain => 1 - } + 'General' => \%configGeneralOpts } }, 'Plugin::PrometheusTiny' => { diff --git a/src/lib/Hydra/Config.pm b/src/lib/Hydra/Config.pm new file mode 100644 index 00000000..8110c2ba --- /dev/null +++ b/src/lib/Hydra/Config.pm @@ -0,0 +1,11 @@ +package Hydra::Config; + +use strict; +use Exporter; + +our @ISA = qw(Exporter); +our @EXPORT = qw(%configGeneralOpts); + +my %configGeneralOpts = (-UseApacheInclude => 1, -IncludeAgain => 1); + +1; diff --git a/src/lib/Hydra/Helper/Nix.pm b/src/lib/Hydra/Helper/Nix.pm index 27b1b15a..6c0c0497 100644 --- a/src/lib/Hydra/Helper/Nix.pm +++ b/src/lib/Hydra/Helper/Nix.pm @@ -5,6 +5,7 @@ use Exporter; use File::Path; use File::Basename; use Config::General; +use Hydra::Config; use Hydra::Helper::CatalystUtils; use Hydra::Model::DB; use Nix::Store; @@ -48,9 +49,7 @@ sub getHydraConfig { # This is necessary in order to maintain consistent interpretation # of the config by the various hydra components. my %h = new Config::General( -ConfigFile => $conf - , -UseApacheInclude => 1 - , -IncludeAgain => 1 - )->getall; + , %configGeneralOpts )->getall; $hydraConfig = \%h; } else {