Skip to content

Commit d2c4cd5

Browse files
authored
Refactor YAML variable definitions and enhance logging in FileItem class (#60)
Standardize variable definitions in YAML files for consistency and improve logging functionality in the FileItem class to aid in debugging.
1 parent c8ae940 commit d2c4cd5

File tree

3 files changed

+21
-16
lines changed

3 files changed

+21
-16
lines changed

struct_module/contribs/configs/kubectl.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ files:
1717
default: "true"
1818
1919
variables:
20-
- name: namespace
21-
description: The name of the namespace to create.
22-
type: string
23-
default: default
20+
- namespace:
21+
description: The name of the namespace to create.
22+
type: string
23+
default: default

struct_module/contribs/github/workflows/execute-tf-workflow.yaml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ files:
2525
gh-token: {{@ github_token @}}
2626
2727
variables:
28-
- name: app_name
29-
description: "The name of the app."
30-
default: "environments-dev"
31-
type: string
32-
- name: app_path
33-
description: "The working directory for the terraform workflow."
34-
default: "environments/dev"
35-
type: string
36-
- name: github_token
37-
description: "The GitHub token for authentication."
38-
default: "${{ secrets.GITHUB_TOKEN }}"
39-
type: string
28+
- app_name:
29+
description: "The name of the app."
30+
default: "environments-dev"
31+
type: string
32+
- app_path:
33+
description: "The working directory for the terraform workflow."
34+
default: "environments/dev"
35+
type: string
36+
- github_token:
37+
description: "The GitHub token for authentication."
38+
default: "${{ secrets.GITHUB_TOKEN }}"
39+
type: string

struct_module/file_item.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,16 @@ def apply_template_variables(self, template_vars):
100100
missing_vars = self.template_renderer.prompt_for_missing_vars(self.content, vars)
101101
vars.update(missing_vars)
102102

103+
self.vars = vars
104+
self.logger.debug(f"Final template variables: {self.vars}")
105+
103106
self.content = self.template_renderer.render_template(self.content, vars)
104107

105108
def create(self, base_path, dry_run=False, backup_path=None, file_strategy='overwrite'):
106109
file_path = os.path.join(base_path, self.name)
107110

111+
file_path = self.template_renderer.render_template(file_path, self.vars)
112+
108113
if self.skip:
109114
self.logger.info(f"skip is set to true. skipping creation.")
110115
return

0 commit comments

Comments
 (0)