Commit 0fcfc5cb authored by Eric Pellegrini's avatar Eric Pellegrini
Browse files

reformatted the output for missing templates

the environment can now also be stored in the manifest.yml file (least preceedence)
parent 601b4817
...@@ -19,11 +19,14 @@ from packme import Packman, __version__ ...@@ -19,11 +19,14 @@ from packme import Packman, __version__
class NotSudo(Exception): class NotSudo(Exception):
pass pass
def clean_templates_dir(templates_base_dir: str): def clean_templates_dir(templates_base_dir: str = None):
"""Removes all manifest.json files, packer_cache and builds directories found in """Removes all manifest.json files, packer_cache and builds directories found in
templates directory templates directory
""" """
if templates_base_dir is None:
templates_base_dir = "templates"
template_dirs = glob.glob(os.path.join(templates_base_dir,"*")) template_dirs = glob.glob(os.path.join(templates_base_dir,"*"))
for template_dir in template_dirs: for template_dir in template_dirs:
...@@ -29,8 +29,14 @@ class PackerTemplate: ...@@ -29,8 +29,14 @@ class PackerTemplate:
self._packages_base_dir = packages_base_dir self._packages_base_dir = packages_base_dir
self._templates_base_dir = templates_base_dir self._templates_base_dir = templates_base_dir
# First check whether the manifest contains an environment section
self._environment = yaml_node.get("environment", {})
# Then update this environment with the one found in environment.yml file
environment_file = os.path.join(self._templates_base_dir,self._name,"environment.yml") environment_file = os.path.join(self._templates_base_dir,self._name,"environment.yml")
self._read_environment_file(environment_file) self._read_environment_file(environment_file)
# Finally take the global environment as the one with highest precedence
self._environment.update(os.environ) self._environment.update(os.environ)
# Fetch the 'packer' node # Fetch the 'packer' node
...@@ -284,7 +290,7 @@ class PackerTemplate: ...@@ -284,7 +290,7 @@ class PackerTemplate:
# If there are some undefined templates, stop here. # If there are some undefined templates, stop here.
if undefined: if undefined:
print(f'The following variables are undefined: {undefined!r}') print(f'The following templates could not rendered: {sorted(undefined)!r}')
sys.exit(1) sys.exit(1)
template = env.from_string(stringified_node) template = env.from_string(stringified_node)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment