Fix formatting inconsistencies in README, Terraform scripts, and example variables
This commit is contained in:
@@ -196,16 +196,16 @@ def generate_report(
|
||||
Guidelines:
|
||||
- The list of changes above must be reproduced verbatim in the report under a "Planned Changes" section, preserving the grouping.
|
||||
- Focus exclusively on what is changing and whether it is expected.
|
||||
- Deletions and replacements are highest priority — analyse each one individually: why might it be deleted or replaced, and is that intentional?
|
||||
- Deletions and replacements are highest priority - analyse each one individually: why might it be deleted or replaced, and is that intentional?
|
||||
- For updates and creates, note anything surprising in scope or naming.
|
||||
- Do not include implementation advice — the plan is already the product of implementation.
|
||||
- Do not include implementation advice - the plan is already the product of implementation.
|
||||
- Do not pad with generic statements.
|
||||
|
||||
Structure:
|
||||
1. **Change Summary** — one-paragraph overview of the overall scope
|
||||
2. **Planned Changes** — verbatim list from above
|
||||
3. **Deletions & Replacements Analysis** — only if any exist; individual analysis per resource
|
||||
4. **Scope Review** — does the set of changes look coherent and complete? flag anomalies"""
|
||||
1. **Change Summary** - one-paragraph overview of the overall scope
|
||||
2. **Planned Changes** - verbatim list from above
|
||||
3. **Deletions & Replacements Analysis** - only if any exist; individual analysis per resource
|
||||
4. **Scope Review** - does the set of changes look coherent and complete? flag anomalies"""
|
||||
|
||||
system_instruction = "You are a senior infrastructure engineer reviewing a Terraform plan before it is applied. Your job is to identify whether the changes match the deployment intent and surface anything worth scrutinising."
|
||||
|
||||
@@ -214,11 +214,11 @@ Structure:
|
||||
from google import genai
|
||||
from google.genai import types
|
||||
except ImportError:
|
||||
print("❌ Error: google-genai package is not installed. Please install it to use Gemini.", file=sys.stderr)
|
||||
print("[ERROR] google-genai package is not installed. Please install it to use Gemini.", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
if not gcp_project:
|
||||
print("❌ Error: GCP project must be specified via --gcp-project or GOOGLE_CLOUD_PROJECT environment variable for Gemini.", file=sys.stderr)
|
||||
print("[ERROR] GCP project must be specified via --gcp-project or GOOGLE_CLOUD_PROJECT environment variable for Gemini.", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
client = genai.Client(vertexai=True, project=gcp_project, location=gcp_location)
|
||||
@@ -339,36 +339,36 @@ def main():
|
||||
plan_file = Path.cwd() / plan_file
|
||||
|
||||
if not plan_file.exists():
|
||||
print(f"❌ Error: {plan_file} not found", file=sys.stderr)
|
||||
print(f"[ERROR] {plan_file} not found", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
print(f"📋 Loading plan from {plan_file}...", file=sys.stderr)
|
||||
print(f"[INFO] Loading plan from {plan_file}...", file=sys.stderr)
|
||||
plan = load_plan(plan_file)
|
||||
|
||||
print("🔍 Extracting resource changes...", file=sys.stderr)
|
||||
print("[INFO] Extracting resource changes...", file=sys.stderr)
|
||||
categorised = extract_resource_changes(plan)
|
||||
total = sum(len(v) for v in categorised.values())
|
||||
|
||||
if not categorised:
|
||||
print("⚠️ No resource changes found in the plan", file=sys.stderr)
|
||||
print("[WARN] No resource changes found in the plan", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
for action in ACTION_ORDER:
|
||||
count = len(categorised.get(action, []))
|
||||
if count:
|
||||
print(f" {ACTION_LABELS[action]}: {count}", file=sys.stderr)
|
||||
print(f"✅ Total changes: {total}", file=sys.stderr)
|
||||
print(f"[OK] Total changes: {total}", file=sys.stderr)
|
||||
|
||||
# Generate report
|
||||
if args.ai:
|
||||
if args.gemini:
|
||||
if args.model == MODEL_DEFAULT:
|
||||
args.model = "gemini-2.5-flash"
|
||||
print(f"🚀 Generating AI report with Gemini ({args.model})...", file=sys.stderr)
|
||||
print(f"[INFO] Generating AI report with Gemini ({args.model})...", file=sys.stderr)
|
||||
elif args.azure_endpoint:
|
||||
print(f"🚀 Generating AI report with Azure OpenAI ({args.model})...", file=sys.stderr)
|
||||
print(f"[INFO] Generating AI report with Azure OpenAI ({args.model})...", file=sys.stderr)
|
||||
else:
|
||||
print(f"🚀 Generating AI report with OpenAI endpoint ({args.model})...", file=sys.stderr)
|
||||
print(f"[INFO] Generating AI report with OpenAI endpoint ({args.model})...", file=sys.stderr)
|
||||
|
||||
report_start = time.time()
|
||||
report = generate_report(
|
||||
@@ -384,9 +384,9 @@ def main():
|
||||
args.gcp_location
|
||||
)
|
||||
report_elapsed = time.time() - report_start
|
||||
print(f" ✓ Completed in {report_elapsed:.2f}s", file=sys.stderr)
|
||||
print(f" [OK] Completed in {report_elapsed:.2f}s", file=sys.stderr)
|
||||
else:
|
||||
print("📄 Generating plain report...", file=sys.stderr)
|
||||
print("[INFO] Generating plain report...", file=sys.stderr)
|
||||
report = generate_plain_report(categorised, plan)
|
||||
|
||||
# Determine output filename
|
||||
@@ -402,12 +402,12 @@ def main():
|
||||
with open(output_file, "w") as f:
|
||||
f.write(report)
|
||||
|
||||
print(f"📄 Report written to {output_file}", file=sys.stderr)
|
||||
print(f"[INFO] Report written to {output_file}", file=sys.stderr)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
main()
|
||||
except KeyboardInterrupt:
|
||||
print("\n⚠️ Interrupted by user", file=sys.stderr)
|
||||
print("\n[WARN] Interrupted by user", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
Reference in New Issue
Block a user