docs: make compose inventory generation deterministic
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env python3
|
||||
import hashlib
|
||||
import sys, yaml
|
||||
from datetime import datetime, timezone
|
||||
|
||||
def md(v): return str(v).replace('|','\\|') if v is not None else ''
|
||||
|
||||
@@ -9,7 +9,9 @@ with open(inp) as f: c=yaml.safe_load(f) or {}
|
||||
svcs=c.get('services',{}) or {}
|
||||
nets=c.get('networks',{}) or {}
|
||||
vols=c.get('volumes',{}) or {}
|
||||
lines=["# Docker Compose Inventory","",f"Generated: {datetime.now(timezone.utc).strftime('%Y-%m-%dT%H:%M:%SZ')}","","## Summary","","| Item | Count |","|---|---:|",f"| Services | {len(svcs)} |",f"| Networks | {len(nets)} |",f"| Volumes | {len(vols)} |","","## Services","","| Service | Container | Image | Build | Profiles | Networks | Ports | Restart |","|---|---|---|---|---|---|---|---|"]
|
||||
raw=open(inp,'rb').read()
|
||||
fingerprint=hashlib.sha256(raw).hexdigest()[:12]
|
||||
lines=["# Docker Compose Inventory","",f"Source fingerprint: `{fingerprint}`","","## Summary","","| Item | Count |","|---|---:|",f"| Services | {len(svcs)} |",f"| Networks | {len(nets)} |",f"| Volumes | {len(vols)} |","","## Services","","| Service | Container | Image | Build | Profiles | Networks | Ports | Restart |","|---|---|---|---|---|---|---|---|"]
|
||||
for n,s in sorted(svcs.items()):
|
||||
build=s.get('build','')
|
||||
if isinstance(build,dict): build=build.get('context','')
|
||||
|
||||
Reference in New Issue
Block a user