Skip to content

Commit da6f0e3

Browse files
authored
Feature/reporting improvements (#9)
* changes and adding documentation * renaming project * renaming project * renaming project * renaming project * adding requirements for docs * changes
1 parent ba85b7d commit da6f0e3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+963
-258
lines changed

.readthedocs.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Read the Docs configuration file
2+
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
3+
4+
# Required
5+
version: 2
6+
7+
# Set the OS, Python version, and other tools you might need
8+
build:
9+
os: ubuntu-24.04
10+
tools:
11+
python: "3.13" # Note: 3.13 is very new, consider using 3.11 for better compatibility
12+
13+
# Build documentation with Mkdocs
14+
mkdocs:
15+
configuration: mkdocs.yml
16+
17+
# Optionally, but recommended,
18+
# declare the Python requirements required to build your documentation
19+
# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
20+
python:
21+
install:
22+
- requirements: docs/requirements.txt
23+

README.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# TFSumPy - Terraform Plan Analyzer
1+
# bolwerk - Terraform Plan Analyzer
22

3-
[![CI](https://github.com/rafaelherik/tfsumpy/actions/workflows/ci.yaml/badge.svg)](https://github.com/rafaelherik/tfsumpy/actions/workflows/ci.yaml)
3+
[![CI](https://github.com/rafaelherik/bolwerk/actions/workflows/ci.yaml/badge.svg)](https://github.com/rafaelherik/bolwerk/actions/workflows/ci.yaml)
44

5-
TFSumPy is a Python-based tool that analyzes Terraform plan files to provide a clear summary of infrastructure changes and identify potential risks. It helps DevOps teams review infrastructure changes more effectively by:
5+
bolwerk is a Python-based tool that analyzes Terraform plan files to provide a clear summary of infrastructure changes and identify potential risks. It helps DevOps teams review infrastructure changes more effectively by:
66

77
- Summarizing resource changes (create, update, delete)
88
- Identifying high and medium risk changes
@@ -23,12 +23,12 @@ TFSumPy is a Python-based tool that analyzes Terraform plan files to provide a c
2323

2424
Install using pip:
2525
```bash
26-
pip install tfsumpy
26+
pip install bolwerk
2727
```
2828
Or install from source:
2929
```bash
30-
git clone https://github.com/rafaelherik/tfsumpy.git
31-
cd tfsumpy
30+
git clone https://github.com/rafaelherik/bolwerk.git
31+
cd bolwerk
3232
pip install .
3333
```
3434
## Usage
@@ -45,27 +45,27 @@ Or install from source:
4545

4646
Basic summary:
4747
```bash
48-
tfsumpy plan.json
48+
bolwerk plan.json
4949
```
5050

5151
Show detailed changes:
5252
```bash
53-
tfsumpy plan.json --changes
53+
bolwerk plan.json --changes
5454
```
5555

5656
Show resource details:
5757
```bash
58-
tfsumpy plan.json --details
58+
bolwerk plan.json --details
5959
```
6060

6161
Enable risk assessment:
6262
```bash
63-
tfsumpy plan.json --risks
63+
bolwerk plan.json --risks
6464
```
6565

6666
Enable policy compliance check:
6767
```bash
68-
tfsumpy plan.json --policies
68+
bolwerk plan.json --policies
6969
```
7070

7171
### Example Output
@@ -93,7 +93,7 @@ Enable policy compliance check:
9393
1. Risk Assessment:
9494

9595
```bash
96-
tfsumpy plan.json --risks
96+
bolwerk plan.json --risks
9797
```
9898

9999
This will show:
@@ -104,7 +104,7 @@ This will show:
104104
2. Policy Compliance:
105105

106106
```bash
107-
tfsumpy plan.json --policies
107+
bolwerk plan.json --policies
108108
```
109109

110110
Checks resources against:
@@ -115,7 +115,7 @@ Checks resources against:
115115
3. Detailed Analysis:
116116

117117
```bash
118-
tfsumpy plan.json --changes --details --risks
118+
bolwerk plan.json --changes --details --risks
119119
```
120120

121121
### Configuration
@@ -144,15 +144,15 @@ Create a custom configuration file (config.json):
144144
Use the configuration:
145145

146146
```bash
147-
tfsumpy plan.json --config config.json
147+
bolwerk plan.json --config config.json
148148
```
149149

150150
### Debug Mode
151151

152152
For troubleshooting or detailed logging:
153153

154154
```bash
155-
tfsumpy plan.json --debug
155+
bolwerk plan.json --debug
156156
```
157157

158158
This will:
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

tfsumpy/db/manager.py renamed to bolwerk/db/manager.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
1-
from typing import Dict, List, Optional
1+
import logging
2+
from pathlib import Path
3+
4+
def __init__(self, db_path: str = None):
5+
26
import sqlite3
37
from pathlib import Path
48
import json
59
import logging
610

711
class DBManager:
8-
"""Global database manager for TFSumPy."""
12+
"""Global database manager for bolwerk."""
913

1014
def __init__(self, db_path: str = None):
1115
if not db_path:
12-
db_path = str(Path.home() / '.tfsumpy' / 'tfsumpy.db')
16+
db_path = str(Path.home() / '.bolwerk' / 'bolwerk.db')
1317

1418
Path(db_path).parent.mkdir(parents=True, exist_ok=True)
1519
self.db_path = db_path
File renamed without changes.

tfsumpy/plan/reporter.py renamed to bolwerk/plan/reporter.py

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,21 @@ def _print_summary(self, report: Dict) -> None:
7575

7676
def _print_resource_details(self, resources: list, show_changes: bool = False) -> None:
7777
"""Format the resource details section."""
78-
self._write(f"\n{self._colorize('Resource Changes:', 'bold')}\n")
78+
self._write(f"\n{self._colorize('Resources Changes:', 'bold')}\n")
79+
80+
# Define color mapping for actions
81+
action_colors = {
82+
'CREATE': 'green',
83+
'UPDATE': 'blue',
84+
'DELETE': 'red'
85+
}
7986

8087
for resource in resources:
8188
action_str = resource['action'].upper()
89+
# Color the action string based on the action type
90+
colored_action = self._colorize(action_str, action_colors.get(action_str, 'bold'))
8291
self._write(
83-
f"\n{action_str} {resource['resource_type']}: "
92+
f"\n{colored_action} {resource['resource_type']}: "
8493
f"{resource['identifier']}\n"
8594
)
8695

@@ -97,16 +106,26 @@ def _print_attribute_changes(self, resource: Dict) -> None:
97106
all_attrs = set(before.keys()) | set(after.keys())
98107
skip_attrs = {'id', 'tags_all'} # Skip internal attributes
99108

109+
# Define color mapping for symbols
110+
symbol_colors = {
111+
'+': 'green', # create
112+
'~': 'blue', # update
113+
'-': 'red' # delete
114+
}
115+
100116
for attr in sorted(all_attrs - skip_attrs):
101117
before_val = before.get(attr)
102118
after_val = after.get(attr)
103119

104120
if before_val != after_val:
105121
if resource['action'] == 'create':
106-
lines.append(f" + {attr} = {after_val}")
122+
symbol = self._colorize('+', symbol_colors['+'])
123+
lines.append(f" {symbol} {attr} = {after_val}")
107124
elif resource['action'] == 'delete':
108-
lines.append(f" - {attr} = {before_val}")
125+
symbol = self._colorize('-', symbol_colors['-'])
126+
lines.append(f" {symbol} {attr} = {before_val}")
109127
else: # update
110-
lines.append(f" ~ {attr} = {before_val} -> {after_val}")
128+
symbol = self._colorize('~', symbol_colors['~'])
129+
lines.append(f" {symbol} {attr} = {before_val} -> {after_val}")
111130

112131
self._write('\n'.join(lines))
File renamed without changes.

0 commit comments

Comments
 (0)