From eb2a159e83f1a2e8651812f88fba3d36440d8349 Mon Sep 17 00:00:00 2001 From: Anuj Hydrabadi Date: Wed, 23 Jul 2025 10:56:20 +0530 Subject: [PATCH] Migrate to pyproject.toml and synchronize readme with command defs --- .github/workflows/ci.yaml | 8 +++---- .gitignore | 4 +++- README.md | 13 +++++++---- pyproject.toml | 49 +++++++++++++++++++++++++++++++++++++++ setup.py | 46 ------------------------------------ 5 files changed, 65 insertions(+), 55 deletions(-) create mode 100644 pyproject.toml delete mode 100644 setup.py diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 59600ea..a0a3f64 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -17,20 +17,20 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: '3.10' + python-version: '3.11' - name: Update version file run: | echo "${{ github.ref_name }}" | sed 's/^v//' > VERSION - - name: Install dependencies + - name: Install build dependencies run: | python -m pip install --upgrade pip - pip install setuptools wheel twine + pip install build twine - name: Build package run: | - python setup.py sdist bdist_wheel + python -m build - name: Publish to PyPI env: diff --git a/.gitignore b/.gitignore index 62e6b38..b2e61b4 100644 --- a/.gitignore +++ b/.gitignore @@ -79,4 +79,6 @@ dotenv .venv/ # Claude AI local settings -.claude/settings.local.json \ No newline at end of file +.claude/settings.local.json + +uv.lock diff --git a/README.md b/README.md index 82fadcf..c402e2f 100644 --- a/README.md +++ b/README.md @@ -49,8 +49,8 @@ To install FTF CLI from source, follow these steps: 2. **Create a virtual environment** (recommended): ```bash - python -m venv env - source env/bin/activate # On Windows use `env\Scripts\activate` + uv sync + source .venv/bin/activate # On Windows use `.venv\Scripts\activate` ``` 3. **Install the package**: @@ -126,6 +126,7 @@ ftf add-variable [OPTIONS] /path/to/module - Preserves terraform formatting while adding variables. - Performs type validation before addition. - Nested variables create the necessary nested structure internally. +- Pattern properties support regex validation for dynamic keys. #### Validate Directory @@ -137,10 +138,11 @@ ftf validate-directory /path/to/module [OPTIONS] **Options**: - `--check-only`: Only check formatting; does not make any changes. +- `--skip-terraform-validation`: Skip Terraform validation steps if set to true. **Notes**: - Runs `terraform fmt` for formatting verification. -- Runs `terraform init` to ensure initialization completeness. +- Runs `terraform init` to ensure initialization completeness (unless skipped). - Uses Checkov to scan Terraform files for security misconfigurations. - Designed for fast feedback on module quality and security. @@ -209,6 +211,8 @@ ftf preview-module /path/to/module [OPTIONS] - `-g, --git-repo-url`: Git repository URL where the module source code resides. - `-r, --git-ref`: Git ref, branch, or tag for the module version. - `--publish`: Flag to publish the module immediately after preview. +- `--skip-terraform-validation`: Skip Terraform validation steps if set to true. +- `--skip-output-write`: Do not update the output type in facets. Set to true only if you have already registered the output type before calling this command. **Notes**: - Environment variables such as GIT_REPO_URL, GIT_REF, FACETS_PROFILE can be used for automation or CI pipelines. @@ -249,6 +253,7 @@ Automatically discovers resources in the module and prompts for selecting a reso - `--resource`: The Terraform resource address to import (e.g., 'aws_s3_bucket.bucket'). - `--index`: For resources with 'count', specify the index (e.g., '0', '1', or '*' for all). - `--key`: For resources with 'for_each', specify the key (e.g., 'my-key' or '*' for all). +- `--resource-address`: The full resource address to import (e.g., 'azurerm_key_vault.for_each_key_vault[0]'). If provided, runs in non-interactive mode and skips resource discovery. **Examples**: ```bash @@ -292,7 +297,7 @@ ftf delete-module [OPTIONS] - `-i, --intent`: (prompt) Intent of the module to delete. - `-f, --flavor`: (prompt) Flavor of the module. - `-v, --version`: (prompt) Version of the module. -- `-s, --stage`: (prompt) Deployment stage of the module. +- `-s, --stage`: (prompt) Deployment stage of the module (choices: "PUBLISHED", "PREVIEW"). - `-p, --profile`: (prompt) Authentication profile to use (default: "default"). #### Get Output Types diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..85b401d --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,49 @@ +[build-system] +requires = ["setuptools>=45", "wheel", "setuptools_scm[toml]>=6.2"] +build-backend = "setuptools.build_meta" + +[project] +name = "ftf-cli" +description = "Facets Terraform Cli" +authors = [ + {name = "Sanmesh Kakade", email = "sanmesh.kakade@facets.cloud"} +] +keywords = ["Facets", "CLI", "Terraform"] +readme = "README.md" +requires-python = ">=3.11" +dynamic = ["version"] + +dependencies = [ + "Click", + "Jinja2", + "PyYAML", + "checkov", + "jsonschema", + "requests", + "questionary", + "facets-hcl", + "ruamel.yaml", +] + +[project.optional-dependencies] +dev = [ + "pytest>=8.3.5", + "pytest-mock", + "pyhcl>=0.4.5", +] + +[project.urls] +Homepage = "https://github.com/Facets-cloud/module-development-cli" +Repository = "https://github.com/Facets-cloud/module-development-cli" + +[project.scripts] +ftf = "ftf_cli.cli:cli" + +[tool.setuptools.packages.find] +include = ["ftf_cli", "ftf_cli.commands", "ftf_cli.commands.templates"] + +[tool.setuptools] +include-package-data = true + +[tool.setuptools.dynamic] +version = {file = "VERSION"} diff --git a/setup.py b/setup.py deleted file mode 100644 index a9803bb..0000000 --- a/setup.py +++ /dev/null @@ -1,46 +0,0 @@ -from setuptools import setup, find_packages - -with open("VERSION", "r") as version_file: - version = version_file.read().strip() - -with open("README.md", "r", encoding="utf-8") as fh: - long_description = fh.read() - -setup( - name="ftf-cli", - version=version, - description="Facets Terraform Cli", - long_description=long_description, - long_description_content_type="text/markdown", - author="Sanmesh Kakade", - author_email="sanmesh.kakade@facets.cloud", - url="https://github.com/Facets-cloud/module-development-cli", - keywords=["Facets", "CLI", "Terraform"], - install_requires=[ - "Click", - "Jinja2", - "PyYAML", - "checkov", - "jsonschema", - "requests", - "questionary", - "facets-hcl", - "ruamel.yaml", - ], - packages=find_packages( - include=["ftf_cli", "ftf_cli.commands", "ftf_cli.commands.templates"] - ), - include_package_data=True, - extras_require={ - "dev": [ - "pytest>=8.3.5", - "pytest-mock", - "pyhcl>=0.4.5", - ], - }, - entry_points=""" - [console_scripts] - ftf=ftf_cli.cli:cli - """, - python_requires=">=3.11", -)