Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TaskCat Config Generator #820

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

TaskCat Config Generator #820

wants to merge 4 commits into from

Conversation

tbulding
Copy link

@tbulding tbulding commented Mar 26, 2024

Overview

This change adds the ability to generate the .taskcat.yml config file based on a CloudFormation template. The tool can generate the configuration file with verbose information (-v) about the parameters.(This information is taken from the CFN)
The tool also offers the option to generate a .taskcat_overrides.yml file (-c). The tool attempts to populate empty values based on the parameter name.

Testing/Steps taken to ensure quality

How did you validate the changes in this PR?
I ran the tool against a 15 different Quick Start projects.

Notes

Optional. Caveats, Alternatives, Other relevant information.

Testing Instructions

To test this PR you will need to install Taskcat From the Originating fork. Clone the Forked repo, and from the root of the repo run:
python setup.py install
Once taskcat is installed you can run it against an existing template with:

taskcat generate-tc-config -m templates/your_template.template.yaml -c

Copy link
Contributor

@andrew-glenn andrew-glenn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally, a well intended review and I 💯 appreciate the thought and effort. I think this will need a few iterations before it's ready to merge. Feel free to reach out internally to discuss.

taskcat/project_config/tools.py Outdated Show resolved Hide resolved
taskcat/project_config/tools.py Outdated Show resolved Hide resolved
taskcat/project_config/tools.py Outdated Show resolved Hide resolved
taskcat/project_config/tc_config.py Outdated Show resolved Hide resolved
Comment on lines 77 to 100
if self.create_overrides_file:
m = open(f'{self.project_root_path}/.taskcat_overrides.yml',
"w+",
encoding="utf-8")
p_overrides = []
p_blanks = []
p_default = []
for p in parameters:
if parameters[p] == 'OVERRIDE':
p_overrides.append(f'{p}: OVERRIDE\r\n')
elif parameters[p] == '':
p_blanks.append(f'{p}: ""\r\n')
else:
p_default.append(f'{p}: {parameters[p]}\r\n')
p_overrides.sort()
p_blanks.sort()
p_default.sort()
m.write("# OVERRIDES\r\n")
m.write(''.join(p_overrides))
m.write("# BLANKS\r\n")
m.write(''.join(p_blanks))
m.write("# DEFAULTS\r\n")
m.write(''.join(p_default))
m.close()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? If there's no config, there's nothing to overwrite; In my mind, the intended purposes of this feature is to generate a basic config given a template;

If a parameter has a default value, use that.

taskcat/project_config/tools.py Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants