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.
This commit is contained in:
matze 2020-07-23 21:41:47 +02:00
commit 7f95bbd535
3 changed files with 7 additions and 1 deletions

View file

@ -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(

View file

@ -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(

View file

@ -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")