From 3bb26c48849a7d3e7548c2c9036282ffb41aced3 Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Thu, 29 Dec 2022 14:14:10 +0100 Subject: [PATCH] make templates and commands directories as well as values.yaml optional (to enable override projects) --- nothelm/lib/template.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/nothelm/lib/template.py b/nothelm/lib/template.py index d7d3975..ae259fb 100644 --- a/nothelm/lib/template.py +++ b/nothelm/lib/template.py @@ -42,11 +42,19 @@ def template_project( This is so that we can merge multiple project folders into one """ - default_values = load_values(f'{project_dir}/values.yaml') + + if os.path.exists(f'{project_dir}/values.yaml'): + default_values = load_values(f'{project_dir}/values.yaml') + else: + default_values = dict() + values = merge_single(default_values, custom_values) - template_dir(project_dir + '/templates', target_dir + '/templates', all_files_as_template, strip_template_file_endings, values) - template_dir(project_dir + '/commands', target_dir + '/commands', all_files_as_template, strip_template_file_endings, values) + if os.path.exists(project_dir + '/templates'): + template_dir(project_dir + '/templates', target_dir + '/templates', all_files_as_template, strip_template_file_endings, values) + + if os.path.exists(project_dir + '/commands'): + template_dir(project_dir + '/commands', target_dir + '/commands', all_files_as_template, strip_template_file_endings, values) def template_dir(