From: Frank Brehm Date: Thu, 14 Mar 2019 16:55:58 +0000 (+0100) Subject: Moving property puppet_root_env_dir from class GetForgeModulesApp to BaseHookApp X-Git-Tag: 1.6.4^2~28 X-Git-Url: https://git.uhu-banane.net/?a=commitdiff_plain;h=712569beb6d23e53bb5042900bfdc61e8a2843fe;p=pixelpark%2Fpuppetmaster-webhooks.git Moving property puppet_root_env_dir from class GetForgeModulesApp to BaseHookApp --- diff --git a/lib/webhooks/base_app.py b/lib/webhooks/base_app.py index 8302524..1239eef 100644 --- a/lib/webhooks/base_app.py +++ b/lib/webhooks/base_app.py @@ -176,6 +176,7 @@ class BaseHookApp(BaseApplication): description = _("Base gitlab webhook application.") self._data_dir = self.default_data_dir + self._puppet_root_env_dir = self.puppet_envs_dir self._read_stdin = True self.tz_name = self.default_tz_name self._html_title = None @@ -460,6 +461,16 @@ class BaseHookApp(BaseApplication): def data_dir(self, value): self._data_dir = pathlib.Path(value) + # ----------------------------------------------------------- + @property + def puppet_root_env_dir(self): + """The directory containing the Puppet environment directories.""" + return self._puppet_root_env_dir + + @puppet_root_env_dir.setter + def puppet_root_env_dir(self, value): + self._puppet_root_env_dir = pathlib.Path(value) + # ----------------------------------------------------------- @property def log_directory(self): @@ -537,6 +548,7 @@ class BaseHookApp(BaseApplication): res['cgi_bin_dir'] = self.cgi_bin_dir res['log_directory'] = self.log_directory res['data_dir'] = self.data_dir + res['puppet_root_env_dir'] = self.puppet_root_env_dir res['error_logfile'] = self.error_logfile res['logfile'] = self.logfile res['puppetlabs_cfg_dir'] = self.puppetlabs_cfg_dir @@ -715,6 +727,17 @@ class BaseHookApp(BaseApplication): path = self.base_dir / path self.data_dir = path + if 'puppet_env_dir' in config and config['puppet_env_dir']: + path = pathlib.Path(config['puppet_env_dir']) + if path.is_absolute(): + self._puppet_root_env_dir = path.resolve() + else: + msg = _( + "Path for the Puppet environments {p!r} must be " + "an absolute path in {f!r}.").format( + p=str(path), f=yaml_file) + self.error_data.append(msg) + if 'cachefile' in config: self._cachefile = pathlib.Path(config['cachefile']) elif 'cache_file' in config: diff --git a/lib/webhooks/get_forge_modules.py b/lib/webhooks/get_forge_modules.py index e4f28ed..ed0459e 100644 --- a/lib/webhooks/get_forge_modules.py +++ b/lib/webhooks/get_forge_modules.py @@ -80,7 +80,6 @@ class GetForgeModulesApp(BaseHookApp): self.environments = [] self.env_modules = {} self.forge_modules = None - self.puppet_root_env_dir = self.puppet_envs_dir self.forge_uri = self.default_forge_uri self.http_timeout = self.default_http_timeout self.modules = None @@ -164,17 +163,6 @@ class GetForgeModulesApp(BaseHookApp): super(GetForgeModulesApp, self).evaluate_config(config, yaml_file) - if 'puppet_env_dir' in config and config['puppet_env_dir']: - path = pathlib.Path(config['puppet_env_dir']) - if path.is_absolute(): - self.puppet_root_env_dir = path.resolve() - else: - msg = _( - "Path for the Puppet environments {p!r} must be " - "an absolute path in {f!r}.").format( - p=str(path), f=yaml_file) - self.error_data.append(msg) - if 'forge_uri' in config and config['forge_uri'] and str(config['forge_uri']).strip(): self.forge_uri = str(config['forge_uri']).strip()