41 lines
1.4 KiB
Python
41 lines
1.4 KiB
Python
import os
|
|
import re
|
|
import paramiko
|
|
|
|
manifest_root = r"c:\Users\Snarf\OneDrive\Desktop\code\SnarfCode\homelab-gitops-repo\manifests"
|
|
|
|
print("=== GITOPS MANIFEST IMAGE AUDIT ===")
|
|
|
|
image_re = re.compile(r'image:\s*([^\s"\']+)', re.IGNORECASE)
|
|
chart_re = re.compile(r'chart:\s*([^\s"\']+)', re.IGNORECASE)
|
|
version_re = re.compile(r'version:\s*([^\s"\']+)', re.IGNORECASE)
|
|
|
|
manifest_data = {}
|
|
|
|
for root, dirs, files in os.walk(manifest_root):
|
|
for f in files:
|
|
if f.endswith('.yaml') or f.endswith('.yml'):
|
|
path = os.path.join(root, f)
|
|
rel_path = os.path.relpath(path, manifest_root)
|
|
with open(path, 'r', encoding='utf-8', errors='ignore') as fp:
|
|
content = fp.read()
|
|
images = image_re.findall(content)
|
|
charts = chart_re.findall(content)
|
|
versions = version_re.findall(content)
|
|
if images or charts:
|
|
manifest_data[rel_path] = {
|
|
'images': list(set(images)),
|
|
'charts': list(set(charts)),
|
|
'versions': list(set(versions))
|
|
}
|
|
|
|
for rel_path, data in sorted(manifest_data.items()):
|
|
print(f"\nFile: {rel_path}")
|
|
if data['images']:
|
|
print(" Images:", ", ".join(data['images']))
|
|
if data['charts']:
|
|
print(" Charts:", ", ".join(data['charts']))
|
|
if data['versions']:
|
|
print(" Versions:", ", ".join(data['versions']))
|
|
|