Added wiki generator
This commit is contained in:
@@ -108,20 +108,45 @@ def main():
|
||||
output_file = sys.argv[1]
|
||||
|
||||
try:
|
||||
with open(output_file, 'r') as f:
|
||||
terraform_output = json.load(f)
|
||||
# Check if file exists and has content
|
||||
if not os.path.exists(output_file):
|
||||
print(f"ERROR: File {output_file} not found")
|
||||
sys.exit(1)
|
||||
|
||||
file_size = os.path.getsize(output_file)
|
||||
if file_size == 0:
|
||||
print(f"ERROR: File {output_file} is empty")
|
||||
sys.exit(1)
|
||||
|
||||
# Извлекаем данные приложений
|
||||
print(f"📄 Reading Terraform output file: {output_file} ({file_size} bytes)")
|
||||
|
||||
# Read and show first few chars for debugging
|
||||
with open(output_file, 'r') as f:
|
||||
content = f.read()
|
||||
print(f"🔍 File content preview: {content[:100]}...")
|
||||
|
||||
# Parse JSON
|
||||
try:
|
||||
terraform_output = json.loads(content)
|
||||
except json.JSONDecodeError as e:
|
||||
print(f"ERROR: Invalid JSON in {output_file}: {e}")
|
||||
print(f"Content starts with: {content[:50]}")
|
||||
sys.exit(1)
|
||||
|
||||
# Extract application data
|
||||
apps_data = terraform_output.get('applications_for_wiki', {}).get('value', {})
|
||||
|
||||
if not apps_data:
|
||||
print("ERROR: No applications_for_wiki output found in Terraform output")
|
||||
print(f"Available outputs: {list(terraform_output.keys())}")
|
||||
sys.exit(1)
|
||||
|
||||
# Генерируем Markdown
|
||||
print(f"📊 Found {len(apps_data.get('proxy_apps', {}))} proxy apps, {len(apps_data.get('oauth_apps', {}))} oauth apps")
|
||||
|
||||
# Generate Markdown
|
||||
markdown_content = generate_markdown_table(apps_data)
|
||||
|
||||
# Записываем результат
|
||||
# Write result
|
||||
wiki_file = "Applications.md"
|
||||
with open(wiki_file, 'w', encoding='utf-8') as f:
|
||||
f.write(markdown_content)
|
||||
@@ -129,12 +154,6 @@ def main():
|
||||
print(f"✅ Wiki page generated: {wiki_file}")
|
||||
print(f"📊 Total applications: {len(apps_data.get('proxy_apps', {})) + len(apps_data.get('oauth_apps', {}))}")
|
||||
|
||||
except FileNotFoundError:
|
||||
print(f"ERROR: File {output_file} not found")
|
||||
sys.exit(1)
|
||||
except json.JSONDecodeError as e:
|
||||
print(f"ERROR: Invalid JSON in {output_file}: {e}")
|
||||
sys.exit(1)
|
||||
except Exception as e:
|
||||
print(f"ERROR: {e}")
|
||||
sys.exit(1)
|
||||
|
||||
Reference in New Issue
Block a user