Skip to content

Commit ad155f0

Browse files
committed
Release v0.3.0
1 parent df7ed36 commit ad155f0

File tree

19 files changed

+667
-147
lines changed

19 files changed

+667
-147
lines changed

CHANGELOG.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,34 @@
11
# Changelog
22

3+
## [0.3.0] - 2025-06-16
4+
5+
### 🚀 New Features
6+
7+
- Added AI-driven plan analysis agent (PlanAnalysisAgent) with Azure context integration.
8+
- Introduced `replace` attribute capture in plan analyzer for accurate reporting of resource replacements.
9+
- Flattened single-element action lists in plan analysis to simplify actions representation.
10+
11+
### 🐛 Bug Fixes
12+
13+
- Skipped no-op changes properly in plan analyzer to avoid redundant entries.
14+
- Fixed reporting of replacement operations in plan reporter.
15+
16+
### 📖 Documentation Improvements
17+
18+
- Updated README and documentation for AI analysis and enhanced command-line usage.
19+
- Refreshed advanced usage and API docs to reflect new features and configurations.
20+
21+
### ⬆️ Dependencies
22+
23+
- Added `backoff` for improved retry and error handling.
24+
25+
### ⚙️ Other Changes
26+
27+
- Removed deprecated `scripts/install_ai_deps.sh`.
28+
- Refactored base reporter and context management for consistency.
29+
30+
---
31+
332
## [0.2.0] - 2024-06-15
433

534
### 🎨 Enhanced Output Formats and CLI Arguments

README.md

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ tfsumpy is a Python-based tool that summarizes Terraform plan files to provide a
1212
- 🔒 Automatic sensitive information redaction
1313
- 🎨 Color-coded output for better readability
1414
- 🔄 Detailed attribute change tracking
15+
- ♻️ Replacement detection: flags resources being recreated and shows enforcing attributes
1516
- 📝 Template-based markdown output
1617
- 🔧 Extensible plugin system
1718
- 🤖 AI-powered change summarization (OpenAI, Gemini, Anthropic)
@@ -35,10 +36,10 @@ terraform show -json tfplan > plan.json
3536
# Basic summary
3637
tfsumpy plan.json
3738

38-
# Show detailed changes
39-
tfsumpy plan.json --hide-changes=false
39+
# Hide attribute changes (optional)
40+
tfsumpy plan.json --hide-changes
4041

41-
# Show resource details
42+
# Show detailed resource information (with attribute changes)
4243
tfsumpy plan.json --detailed
4344
```
4445

@@ -57,17 +58,12 @@ tfsumpy plan.json --output json
5758

5859
## AI Summarization
5960

60-
Enable AI-powered change summarization using OpenAI, Gemini, or Anthropic:
61+
Enable AI-powered change summarization using OpenAI:
6162

6263
```bash
6364
# Using OpenAI
6465
tfsumpy plan.json --output markdown --ai openai YOUR_API_KEY
6566

66-
# Using Google Gemini
67-
tfsumpy plan.json --output markdown --ai gemini YOUR_API_KEY
68-
69-
# Using Anthropic Claude
70-
tfsumpy plan.json --output markdown --ai anthropic YOUR_API_KEY
7167
```
7268

7369
## Configuration

docs/api/models.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class ResourceChange:
2323
module: str = 'root' # Module path (e.g., 'root', 'network.vpc')
2424
before: Dict = None # State before the change
2525
after: Dict = None # State after the change
26+
replace: List[str] = None # Attributes enforcing resource replacement (if any)
2627
```
2728

2829
**Fields:**
@@ -32,7 +33,8 @@ class ResourceChange:
3233
- `changes`: List of changed attributes (may be empty)
3334
- `module`: Module path (default 'root')
3435
- `before`: Dictionary of the resource's state before the change
35-
- `after`: Dictionary of the resource's state after the change
36+
- `after`: Dictionary of the resource's state after the change
37+
- `replace`: List of attributes enforcing resource replacement (if any)
3638

3739
---
3840

docs/api/reporters.md

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,32 @@ from tfsumpy.plan.reporter import PlanReporter
4848

4949
reporter = PlanReporter()
5050

51-
# Console output
52-
reporter.print_report(plan_results, show_changes=True)
51+
# Console output (with optional AI and Azure integration)
52+
reporter.print_report(
53+
plan_results,
54+
show_changes=True,
55+
ai_config=ai_config, # AI settings dict or None
56+
azure_config=azure_config # Azure integration settings dict or None
57+
)
5358

5459
# Markdown output
5560
reporter.print_report_markdown(plan_results, show_changes=True)
5661

57-
# JSON output
58-
reporter.print_report_json(plan_results, show_changes=True)
62+
# JSON output (with optional AI and Azure integration)
63+
reporter.print_report_json(
64+
plan_results,
65+
show_changes=True,
66+
ai_config=ai_config,
67+
azure_config=azure_config
68+
)
5969
```
6070

6171
**Parameters:**
6272
- `data`: The analysis results (from `PlanAnalyzer`)
6373
- `show_changes`: Show detailed attribute changes (bool)
6474
- `show_details`: Show full resource details (bool)
75+
- `ai_config`: Optional AI configuration dict for summarization
76+
- `azure_config`: Optional Azure integration configuration dict for AI enrichment
6577

6678
**Output Formats:**
6779

docs/usage/advanced_usage.md

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,27 @@ Template-based Markdown output with:
1818
- Summary statistics
1919
- Resource changes
2020
- Detailed attribute changes (if enabled)
21-
- Timestamp and metadata
21+
+ Timestamp and metadata
22+
23+
## AI Analysis with Azure
24+
When Azure integration is enabled via the `--azure` flag, tfsumpy will retrieve Azure resource details before performing AI summarization.
25+
Ensure your Azure credentials (e.g., via Azure CLI login or environment variables) and subscription ID are configured.
26+
27+
Example:
28+
```bash
29+
tfsumpy plan.json \
30+
--output markdown \
31+
--ai openai YOUR_API_KEY \
32+
--azure
33+
```
34+
35+
For JSON output with AI and Azure:
36+
```bash
37+
tfsumpy plan.json \
38+
--output json \
39+
--ai openai YOUR_API_KEY \
40+
--azure
41+
```
2242

2343
### JSON Output
2444
```bash
@@ -89,7 +109,7 @@ This enables:
89109

90110
### Deprecated Options
91111
The following options are deprecated and will be removed in a future version:
92-
- `--changes` → Use `--hide-changes=false` instead
112+
- `--changes`: (deprecated; attribute changes are shown by default)
93113
- `--details` → Use `--detailed` instead
94114
- `--markdown` → Use `--output markdown` instead
95115

@@ -98,19 +118,20 @@ The following options are deprecated and will be removed in a future version:
98118
- `--plugin-dir`: Directory to load plugins from
99119
- `--debug`: Enable debug logging
100120

101-
## Markdown Output (Beta)
121+
## Markdown Output
102122

103-
You can generate a Markdown summary of your Terraform plan with:
123+
Generate a Markdown summary of your Terraform plan with:
104124

105125
```bash
106-
tfsumpy plan.json --markdown > plan_summary.md
126+
tfsumpy plan.json --output markdown > plan_summary.md
107127
```
108128

109-
This will create a Markdown file with:
110-
- A summary section
111-
- Sections for created, updated, and destroyed resources
112-
- JSON code blocks for each resource change
113-
114-
For updates, both before and after states are shown. For creates and deletes, only the relevant state is shown.
129+
You can further control the content with:
130+
- `--detailed`: Show detailed resource information and attribute changes
131+
- `--hide-changes`: Hide detailed attribute changes
115132

116-
> **Note:** Markdown output is a beta feature. Please report any issues or suggestions!
133+
The generated Markdown includes:
134+
- Summary statistics
135+
- Resource changes formatted as HCL code blocks
136+
- Replacement enforcement attributes (for recreate operations)
137+
- Timestamp and metadata

docs/usage/command_line.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,18 @@ tfsumpy [OPTIONS] PLAN_FILE
3434
- `--ai-temperature N`: Control response creativity (0.0-1.0)
3535
- `--ai-system-prompt PROMPT`: Custom system prompt
3636

37+
### Azure Integration Options
38+
39+
- `--azure`: Enable Azure integration for AI analysis (requires Azure credentials)
40+
- `--azure-subscription-id`: Azure Subscription ID for resource queries (default from AZURE_SUBSCRIPTION_ID env var)
41+
- `--azure-resource-groups`: List of Azure resource group names to filter (default: all)
42+
- `--azure-include-resources`: Include Azure resources information for analysis
43+
3744
### Deprecated Options
3845

3946
> **Warning**: These options are deprecated and will be removed in a future version.
4047
41-
- `--changes`: Use `--hide-changes=false` instead
48+
- `--changes`: (deprecated; attribute changes are shown by default)
4249
- `--details`: Use `--detailed` instead
4350
- `--markdown`: Use `--output markdown` instead
4451

pyproject.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "tfsumpy"
3-
version = "0.2.0"
3+
version = "0.3.0"
44
description = "A Python tool for analyzing Terraform plan files"
55
authors = ["Rafael H de Carvalho <[email protected]>"]
66
readme = "README.md"
@@ -30,10 +30,13 @@ python = "^3.9"
3030
click = "^8.1.7"
3131
rich = "^13.7.0"
3232
jinja2 = "^3.1.2"
33+
colorama = "^0.4.6"
3334
openai = "^1.12.0"
3435
google-generativeai = "^0.3.2"
3536
anthropic = "^0.18.1"
3637
backoff = "^2.2.1"
38+
azure-identity = "^1.12.0"
39+
azure-mgmt-resource = "^20.1.0"
3740

3841
[tool.poetry.group.dev.dependencies]
3942
pytest = "^7.4.3"

pytest.ini

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
[pytest]
22
testpaths = tests
33
python_files = test_*.py
4-
addopts = --verbose
4+
addopts = --verbose
5+
pythonpath = .

scripts/install_ai_deps.sh

Lines changed: 0 additions & 31 deletions
This file was deleted.

tests/cli/test_cli_detailed.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import sys
2+
import warnings
3+
import re
4+
import pytest
5+
from pathlib import Path
6+
from tfsumpy.__main__ import main
7+
8+
9+
@pytest.fixture
10+
def sample_plan():
11+
"""Path to the sample Terraform plan JSON file."""
12+
# Locate repository root from this test file
13+
project_root = Path(__file__).parents[2]
14+
plan_path = project_root / "samples" / "sample1.json"
15+
return str(plan_path)
16+
17+
def test_cli_shows_all_changes(capsys, monkeypatch, sample_plan):
18+
"""Test that running with --detailed shows all resource changes."""
19+
monkeypatch.setattr(sys, "argv", ["tfsumpy", sample_plan, "--detailed"])
20+
# Run CLI and capture output
21+
main()
22+
out = capsys.readouterr().out
23+
# Strip ANSI color codes for assertions
24+
plain = re.compile(r'\x1b\[[0-9;]*m').sub('', out)
25+
# Verify each action type and symbol appears
26+
assert "CREATE aws_s3_bucket" in plain
27+
assert "+" in plain
28+
assert "UPDATE aws_instance" in plain
29+
assert "~" in plain
30+
assert "DELETE aws_security_group" in plain
31+
assert "-" in plain
32+
33+
def test_cli_alias_details_shows_all_changes(capsys, monkeypatch, sample_plan):
34+
"""Test that deprecated --details alias shows resource changes."""
35+
# Suppress deprecation warnings in stderr
36+
warnings.filterwarnings("ignore", category=DeprecationWarning)
37+
monkeypatch.setattr(sys, "argv", ["tfsumpy", sample_plan, "--details"])
38+
main()
39+
out = capsys.readouterr().out
40+
plain = re.compile(r'\x1b\[[0-9;]*m').sub('', out)
41+
assert "CREATE aws_s3_bucket" in plain
42+
assert "+" in plain
43+
assert "UPDATE aws_instance" in plain
44+
assert "~" in plain
45+
assert "DELETE aws_security_group" in plain
46+
assert "-" in plain

0 commit comments

Comments
 (0)