Skip to content

Commit

Permalink
Add validation for 'with' clause to ensure it is a dictionary
Browse files Browse the repository at this point in the history
  • Loading branch information
httpdss committed Nov 18, 2024
1 parent 6bf9f40 commit 372aeb5
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions struct_module/commands/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ def execute(self, args):
# struct: terraform-module
# - .devops/modules/my_module_two:
# struct: terraform-module
# with:
# module_name: my_module_two
def _validate_folders_config(self, folders):
if not isinstance(folders, list):
raise ValueError("The 'folders' key must be a list.")
Expand All @@ -48,6 +50,8 @@ def _validate_folders_config(self, folders):
raise ValueError(f"Dictionary item '{name}' must contain a 'struct' key.")
if not isinstance(content['struct'], str) and not isinstance(content['struct'], list):
raise ValueError(f"The 'struct' value for '{name}' must be a string.")
if 'with' in content and not isinstance(content['with'], dict):
raise ValueError(f"The 'with' value for '{name}' must be a dictionary.")


# Validate the 'variables' key in the configuration file
Expand Down

0 comments on commit 372aeb5

Please sign in to comment.