From bcdfc0eaa369d742e0b5110d5ba3e389e70fe0b4 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Mon, 7 Oct 2019 11:05:04 +0200 Subject: [PATCH] Add support for shell lib directory path --- cdist/core/code.py | 3 +++ cdist/core/manifest.py | 2 ++ cdist/exec/local.py | 3 ++- cdist/shell.py | 1 + cdist/test/code/__init__.py | 2 ++ cdist/test/manifest/__init__.py | 2 ++ docs/src/cdist-reference.rst.sh | 12 ++++++++++++ 7 files changed, 24 insertions(+), 1 deletion(-) diff --git a/cdist/core/code.py b/cdist/core/code.py index 1550880a..6f8d2a97 100644 --- a/cdist/core/code.py +++ b/cdist/core/code.py @@ -56,6 +56,7 @@ gencode-local __type: full qualified path to the type's dir __files: full qualified path to the files dir __target_host_tags: comma spearated list of host tags + __lib: full qualified path to the lib dir returns: string containing the generated code or None @@ -75,6 +76,7 @@ gencode-remote __type: full qualified path to the type's dir __files: full qualified path to the files dir __target_host_tags: comma spearated list of host tags + __lib: full qualified path to the lib dir returns: string containing the generated code or None @@ -107,6 +109,7 @@ class Code(object): '__target_fqdn': self.target_host[2], '__global': self.local.base_path, '__files': self.local.files_path, + '__lib': self.local.lib_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 07af0ef8..ace31d85 100644 --- a/cdist/core/manifest.py +++ b/cdist/core/manifest.py @@ -44,6 +44,7 @@ common: == local.type_path __files: full qualified path to the files dir __target_host_tags: comma spearated list of host tags + __lib: full qualified path to the lib dir initial manifest is: script: full qualified path to the initial manifest @@ -111,6 +112,7 @@ class Manifest(object): '__target_hostname': self.target_host[1], '__target_fqdn': self.target_host[2], '__files': self.local.files_path, + '__lib': self.local.lib_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 f83c85df..f06a4a35 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", "lib", ] class Local(object): @@ -133,6 +133,7 @@ class Local(object): os.path.join(self.manifest_path, "init")) self.type_path = os.path.join(self.conf_path, "type") + self.lib_path = os.path.join(self.conf_path, "lib") def _init_object_marker(self): self.object_marker_file = os.path.join(self.base_path, "object_marker") diff --git a/cdist/shell.py b/cdist/shell.py index 60b6a9f0..97d6e99e 100644 --- a/cdist/shell.py +++ b/cdist/shell.py @@ -78,6 +78,7 @@ class Shell(object): '__manifest': self.local.manifest_path, '__explorer': self.local.global_explorer_path, '__files': self.local.files_path, + '__lib': self.local.lib_path, '__target_host_tags': self.local.target_host_tags, } diff --git a/cdist/test/code/__init__.py b/cdist/test/code/__init__.py index bf80110d..f3aedf86 100644 --- a/cdist/test/code/__init__.py +++ b/cdist/test/code/__init__.py @@ -101,6 +101,7 @@ class CodeTestCase(test.CdistTestCase): self.cdist_object.object_id) self.assertEqual(output_dict['__object_name'], self.cdist_object.name) self.assertEqual(output_dict['__files'], self.local.files_path) + self.assertEqual(output_dict['__lib'], self.local.lib_path) self.assertEqual(output_dict['__target_host_tags'], self.local.target_host_tags) self.assertEqual(output_dict['__cdist_log_level'], @@ -129,6 +130,7 @@ class CodeTestCase(test.CdistTestCase): self.cdist_object.object_id) self.assertEqual(output_dict['__object_name'], self.cdist_object.name) self.assertEqual(output_dict['__files'], self.local.files_path) + self.assertEqual(output_dict['__lib'], self.local.lib_path) self.assertEqual(output_dict['__target_host_tags'], self.local.target_host_tags) self.assertEqual(output_dict['__cdist_log_level'], diff --git a/cdist/test/manifest/__init__.py b/cdist/test/manifest/__init__.py index 68e777a4..1486cc7c 100644 --- a/cdist/test/manifest/__init__.py +++ b/cdist/test/manifest/__init__.py @@ -97,6 +97,7 @@ class ManifestTestCase(test.CdistTestCase): self.local.type_path) self.assertEqual(output_dict['__manifest'], self.local.manifest_path) self.assertEqual(output_dict['__files'], self.local.files_path) + self.assertEqual(output_dict['__lib'], self.local.lib_path) self.assertEqual(output_dict['__target_host_tags'], self.local.target_host_tags) self.assertEqual(output_dict['__cdist_log_level'], @@ -140,6 +141,7 @@ class ManifestTestCase(test.CdistTestCase): self.assertEqual(output_dict['__object_id'], cdist_object.object_id) self.assertEqual(output_dict['__object_name'], cdist_object.name) self.assertEqual(output_dict['__files'], self.local.files_path) + self.assertEqual(output_dict['__lib'], self.local.lib_path) self.assertEqual(output_dict['__target_host_tags'], self.local.target_host_tags) self.assertEqual(output_dict['__cdist_log_level'], diff --git a/docs/src/cdist-reference.rst.sh b/docs/src/cdist-reference.rst.sh index 3ab12fe2..7bb7dc4a 100755 --- a/docs/src/cdist-reference.rst.sh +++ b/docs/src/cdist-reference.rst.sh @@ -81,6 +81,10 @@ confdir/files/ Cdist does not care about this directory besides providing access to it. It is thought to be a general file storage area. +confdir/lib/ + Cdist does not care about this directory besides providing access to it. + It is thought to be a general storage for shell library files. + confdir/manifest/init This is the central entry point. It is an executable (+x bit set) shell script that can use @@ -141,6 +145,10 @@ confdir/type//files by cdist at any time. It can be used for storing supplementary files (like scripts to act as a template or configuration files). +confdir/type//lib + This directory is reserved for user shell library files and will + not be used by cdist at any time. + out/ This directory contains output of cdist and is usually located in a temporary directory and thus will be removed after the run. @@ -235,6 +243,10 @@ __files Directory that contains content from the "files" subdirectories from the configuration directories. Available for: initial manifest, type manifest, type gencode, shell. +__lib + Directory that contains content from the "lib" subdirectories + from the configuration directories. + Available for: initial manifest, type manifest, type gencode, shell. __manifest Directory that contains the initial manifest. Available for: initial manifest, type manifest, shell.