]> Frank Brehm's Git Trees - pixelpark/puppetmaster-webhooks.git/commitdiff
Moving property puppet_root_env_dir from class GetForgeModulesApp to BaseHookApp
authorFrank Brehm <frank.brehm@pixelpark.com>
Thu, 14 Mar 2019 16:55:58 +0000 (17:55 +0100)
committerFrank Brehm <frank.brehm@pixelpark.com>
Thu, 14 Mar 2019 16:55:58 +0000 (17:55 +0100)
lib/webhooks/base_app.py
lib/webhooks/get_forge_modules.py

index 8302524966cfe6f96460f9e44fcf1fbba7304fd4..1239eefeecb9805eaf54c87ed08ac4f6a9a84882 100644 (file)
@@ -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:
index e4f28ed9ca8b75cae06a5f231c0370ca209a0d72..ed0459e99d0129854ab6e31763b96f4a02ea9a6c 100644 (file)
@@ -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()