From 7f95bbd535da3965f1a2209b643bdb34cfc26174 Mon Sep 17 00:00:00 2001 From: Matthias Stecher Date: Thu, 23 Jul 2020 21:41:47 +0200 Subject: [PATCH] Add global library environment variables to local script executions Threads the `conf/library` folder as a further configuration folder and exports it via the `$__library` environment varibale to the manifest and gencode-* scripts. With it, shell scripts can be sourced as library. For types, `$__type/library` must be used instead to reach these scripts. --- cdist/core/code.py | 3 +++ cdist/core/manifest.py | 2 ++ cdist/exec/local.py | 3 ++- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/cdist/core/code.py b/cdist/core/code.py index 1e9b4f80..019300c5 100644 --- a/cdist/core/code.py +++ b/cdist/core/code.py @@ -39,6 +39,8 @@ common: __cdist_type_base_path: full qualified path to the directory where types are defined for use in type emulator == local.type_path + __library: full qualified path to the library folder containing + common code == local.library_path gencode-local script: full qualified path to a types gencode-local @@ -107,6 +109,7 @@ class Code: '__target_fqdn': self.target_host[2], '__global': self.local.base_path, '__files': self.local.files_path, + '__library': self.local.library_path, '__target_host_tags': self.local.target_host_tags, '__cdist_log_level': util.log_level_env_var_val(local.log), '__cdist_log_level_name': util.log_level_name_env_var_val( diff --git a/cdist/core/manifest.py b/cdist/core/manifest.py index 390340d4..382a38e2 100644 --- a/cdist/core/manifest.py +++ b/cdist/core/manifest.py @@ -43,6 +43,7 @@ common: types are defined for use in type emulator == local.type_path __files: full qualified path to the files dir + __library: full qualitfied path to the library dir __target_host_tags: comma spearated list of host tags initial manifest is: @@ -115,6 +116,7 @@ class Manifest: '__target_hostname': self.target_host[1], '__target_fqdn': self.target_host[2], '__files': self.local.files_path, + '__library': self.local.library_path, '__target_host_tags': self.local.target_host_tags, '__cdist_log_level': util.log_level_env_var_val(self.log), '__cdist_log_level_name': util.log_level_name_env_var_val( diff --git a/cdist/exec/local.py b/cdist/exec/local.py index e0aab190..482a32be 100644 --- a/cdist/exec/local.py +++ b/cdist/exec/local.py @@ -36,7 +36,7 @@ import cdist.message from cdist import core import cdist.exec.util as util -CONF_SUBDIRS_LINKED = ["explorer", "files", "manifest", "type", ] +CONF_SUBDIRS_LINKED = ["explorer", "files", "manifest", "type", "library", ] class Local: @@ -123,6 +123,7 @@ class Local: os.path.join(self.manifest_path, "init")) self.type_path = os.path.join(self.conf_path, "type") + self.library_path = os.path.join(self.conf_path, "library") def _init_object_marker(self): self.object_marker_file = os.path.join(self.base_path, "object_marker")