From 3882282288a79cfdc9a211de8b2f6c1fa4deac52 Mon Sep 17 00:00:00 2001 From: SatyendraGollaFacets Date: Mon, 14 Jul 2025 13:08:21 +0530 Subject: [PATCH 1/2] Add iac.validated_files schema validation, tests, and documentation --- README.md | 14 +++++++ ftf_cli/schema.py | 10 +++++ tests/test_utils_validation.py | 69 ++++++++++++++++++++++++++++++++++ 3 files changed, 93 insertions(+) diff --git a/README.md b/README.md index 82fadcf..832fa31 100644 --- a/README.md +++ b/README.md @@ -410,6 +410,20 @@ Found 3 resources: - aws_security_group.sg (with for_each) ``` +## Note on MCP Server Generated Files + +Any new tf file created by the mcp server needs to be added to `facets.yaml` in this block: + +``` +iac: + validated_files: + - variables.tf + - tekton.tf + # ...add any new files here +``` + +This is only for new files created by the mcp server. + ## Contribution Feel free to fork the repository and submit pull requests for any feature enhancements or bug fixes. diff --git a/ftf_cli/schema.py b/ftf_cli/schema.py index c080102..9565967 100644 --- a/ftf_cli/schema.py +++ b/ftf_cli/schema.py @@ -94,6 +94,16 @@ "required": ["primary"], }, "metadata": Draft7Validator.META_SCHEMA, + "iac": { + "type": "object", + "properties": { + "validated_files": { + "type": "array", + "items": {"type": "string"} + } + }, + "additionalProperties": True + }, }, "required": ["intent", "flavor", "version", "description", "spec", "clouds"], } diff --git a/tests/test_utils_validation.py b/tests/test_utils_validation.py index ed0dfb0..47dcc09 100644 --- a/tests/test_utils_validation.py +++ b/tests/test_utils_validation.py @@ -1,6 +1,10 @@ import pytest import click from ftf_cli.utils import check_no_array_or_invalid_pattern_in_spec, check_conflicting_ui_properties +import os +import tempfile +import yaml +from ftf_cli.utils import validate_yaml def test_no_array_type_pass(): @@ -244,3 +248,68 @@ def test_pattern_properties_only_string_types_with_yaml_editor_pass(): } # Should pass silently check_conflicting_ui_properties(spec) + + +def test_facets_yaml_with_valid_iac_block(): + data = { + "intent": "test", + "flavor": "default", + "version": "1.0", + "description": "desc", + "spec": {}, + "clouds": ["aws"], + "iac": { + "validated_files": ["variables.tf", "tekton.tf"] + } + } + # Should pass validation + validate_yaml(data) + + +def test_facets_yaml_with_iac_not_object(): + data = { + "intent": "test", + "flavor": "default", + "version": "1.0", + "description": "desc", + "spec": {}, + "clouds": ["aws"], + "iac": "not-an-object" + } + with pytest.raises(click.UsageError) as excinfo: + validate_yaml(data) + assert "iac" in str(excinfo.value) + + +def test_facets_yaml_with_iac_validated_files_not_array(): + data = { + "intent": "test", + "flavor": "default", + "version": "1.0", + "description": "desc", + "spec": {}, + "clouds": ["aws"], + "iac": { + "validated_files": "not-an-array" + } + } + with pytest.raises(click.UsageError) as excinfo: + validate_yaml(data) + assert "validated_files" in str(excinfo.value) + + +def test_facets_yaml_with_iac_validated_files_array_of_non_strings(): + data = { + "intent": "test", + "flavor": "default", + "version": "1.0", + "description": "desc", + "spec": {}, + "clouds": ["aws"], + "iac": { + "validated_files": [1, 2, 3] + } + } + with pytest.raises(click.UsageError) as excinfo: + validate_yaml(data) + assert "validated_files" in str(excinfo.value) From 78be0890f2646be9e61d74f8a11027a5de7629c4 Mon Sep 17 00:00:00 2001 From: SatyendraGollaFacets Date: Mon, 14 Jul 2025 14:38:53 +0530 Subject: [PATCH 2/2] Remove MCP server note from README as per review --- README.md | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/README.md b/README.md index 832fa31..82fadcf 100644 --- a/README.md +++ b/README.md @@ -410,20 +410,6 @@ Found 3 resources: - aws_security_group.sg (with for_each) ``` -## Note on MCP Server Generated Files - -Any new tf file created by the mcp server needs to be added to `facets.yaml` in this block: - -``` -iac: - validated_files: - - variables.tf - - tekton.tf - # ...add any new files here -``` - -This is only for new files created by the mcp server. - ## Contribution Feel free to fork the repository and submit pull requests for any feature enhancements or bug fixes.