From 34775c66d91e4f0d7da8fa7d0014e6c237b15cbf Mon Sep 17 00:00:00 2001 From: SatyendraGollaFacets Date: Fri, 31 Oct 2025 11:21:34 +0530 Subject: [PATCH 1/2] Add multiple cloud support to generate-module command MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Enable generate-module command to accept multiple clouds with backward compatibility. Users can now specify either single cloud (-c aws) or comma-separated multiple clouds (-c aws,gcp,azure). Changes: - Parse comma-separated cloud input into list in generate_module.py - Update facets.yaml.j2 template to render clouds as proper YAML array - Update README.md documentation with multiple cloud examples Backward compatibility: - Single cloud input continues to work: -c aws → clouds: ['aws'] - Multiple clouds now supported: -c aws,gcp,azure → clouds: ['aws', 'gcp', 'azure'] - Whitespace handling: spaces around commas are automatically stripped 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- README.md | 2 +- ftf_cli/commands/generate_module.py | 4 ++++ ftf_cli/commands/templates/facets.yaml.j2 | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c402e2f..7d5d2a3 100644 --- a/README.md +++ b/README.md @@ -95,7 +95,7 @@ ftf generate-module [OPTIONS] /path/to/module **Options**: - `-i, --intent`: (prompt) The intent or purpose of the module. - `-f, --flavor`: (prompt) The flavor or variant of the module. -- `-c, --cloud`: (prompt) Target cloud provider (e.g. aws, gcp, azure). +- `-c, --cloud`: (prompt) Target cloud provider(s). Supports single (e.g. aws) or comma-separated multiple clouds (e.g. aws,gcp,azure). - `-t, --title`: (prompt) Human-readable title of the module. - `-d, --description`: (prompt) Description outlining module functionality. diff --git a/ftf_cli/commands/generate_module.py b/ftf_cli/commands/generate_module.py index 4a85a1b..b8c59e6 100644 --- a/ftf_cli/commands/generate_module.py +++ b/ftf_cli/commands/generate_module.py @@ -57,6 +57,9 @@ def generate_module(path, intent, flavor, cloud, title, description, version): templates_path = pkg_resources.files("ftf_cli.commands.templates") env = Environment(loader=FileSystemLoader(str(templates_path))) + # Parse cloud input: supports both single ("aws") and multiple ("aws,azure,gcp") + cloud_list = [c.strip() for c in cloud.split(',')] + # Render and write templates for template_name in [ "main.tf.j2", @@ -69,6 +72,7 @@ def generate_module(path, intent, flavor, cloud, title, description, version): intent=intent, flavor=flavor, cloud=cloud, + clouds=cloud_list, title=title, description=description, ) diff --git a/ftf_cli/commands/templates/facets.yaml.j2 b/ftf_cli/commands/templates/facets.yaml.j2 index 67b849c..97e7403 100644 --- a/ftf_cli/commands/templates/facets.yaml.j2 +++ b/ftf_cli/commands/templates/facets.yaml.j2 @@ -1,7 +1,7 @@ intent: {{ intent }} flavor: {{ flavor }} version: "1.0" -clouds: [ {{ cloud }} ] +clouds: {{ clouds }} description: {{ description }} spec: title: {{ title }} From 79f36bb88f84d999b306cd2f1af02e7ed8154430 Mon Sep 17 00:00:00 2001 From: "coderabbitai[bot]" <136622811+coderabbitai[bot]@users.noreply.github.com> Date: Fri, 31 Oct 2025 11:45:53 +0530 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=93=9D=20Add=20docstrings=20to=20`add?= =?UTF-8?q?-multiple-cloud-support`=20(#81)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Docstrings generation was requested by @SatyendraGollaFacets. * https://github.com/Facets-cloud/module-development-cli/pull/80#issuecomment-3471438651 The following files were modified: * `ftf_cli/commands/generate_module.py` Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- ftf_cli/commands/generate_module.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/ftf_cli/commands/generate_module.py b/ftf_cli/commands/generate_module.py index b8c59e6..1551bf5 100644 --- a/ftf_cli/commands/generate_module.py +++ b/ftf_cli/commands/generate_module.py @@ -22,7 +22,24 @@ help="The version of the module. If not provided, the default version will be 1.0. and the module will increment the version number.", ) def generate_module(path, intent, flavor, cloud, title, description, version): - """Generate a new module.""" + """ + Generate a new module by rendering built-in templates into a target directory. + + Parameters: + path (str): Destination base path where the module directory will be created. + intent (str): Intent name used to construct the module path and passed to templates. + flavor (str): Flavor name used to construct the module path and passed to templates. + cloud (str): Cloud identifier or comma-separated list of clouds (e.g., "aws" or "aws,azure"). + title (str): Human-readable title passed into templates. + description (str): Description text passed into templates. + version (str): Version identifier appended to the module path; must not be a digits-only string. + + Raises: + click.UsageError: If `version` is digits-only, if the requested version already exists, or if version parsing fails when attempting to suggest an alternate version. + + Side effects: + Creates the module directory (including parent directories) and writes rendered template files into it. + """ if str(version).isdigit(): raise click.UsageError( f"❌ Version {version} is not a valid version. Use a valid version like 1.0" @@ -81,4 +98,4 @@ def generate_module(path, intent, flavor, cloud, title, description, version): ) # Remove .j2 to get the real file name with open(os.path.join(module_path, file_name), "w", encoding='utf-8') as f: f.write(rendered_content) - click.echo(f"✅ Module generated at: {module_path}") + click.echo(f"✅ Module generated at: {module_path}") \ No newline at end of file