fix: PG array format for tags, entity slug prefixes, archive path handling
- knowledge.go: scan tags as []string from pgx (not JSON) - seed.go: convert tags to PG array format, fix runbook applies_to_type - convert-wiki.py: fix entity slug prefixes to match inventory.yaml (host: not proxmox-host:, ws: not workstation:, service:homelab-mcp with hyphen) - convert-wiki.py: read from archive/knowledge/ since wiki was archived
This commit is contained in:
@@ -6,9 +6,9 @@ from pathlib import Path
|
||||
from hashlib import sha256
|
||||
|
||||
REPO = Path("/Users/dtoro/Projects/oikos")
|
||||
WIKI = REPO / "knowledge/wiki"
|
||||
SOURCES = REPO / "knowledge/sources"
|
||||
GLOSSARY = REPO / "knowledge/GLOSSARY.md"
|
||||
WIKI = REPO / "archive" / "knowledge"
|
||||
SOURCES = REPO / "archive" / "knowledge"
|
||||
GLOSSARY = REPO / "archive" / "knowledge" / "GLOSSARY.md"
|
||||
|
||||
# Maps wiki path components to entity slugs
|
||||
# Format: (path_pattern, entity_slug)
|
||||
@@ -35,8 +35,8 @@ PATH_TO_ENTITY = {
|
||||
"containers/133-seanime": "lxc:seanime",
|
||||
"containers/134-romm": "lxc:romm",
|
||||
# Hosts
|
||||
"hosts/hubris": "proxmox-host:hubris",
|
||||
"hosts/strong": "proxmox-host:strong",
|
||||
"hosts/hubris": "host:hubris",
|
||||
"hosts/strong": "host:strong",
|
||||
# VMs
|
||||
"vms/100-zimaos": "vm:zimaos",
|
||||
"vms/108-haos": "vm:haos",
|
||||
@@ -44,7 +44,7 @@ PATH_TO_ENTITY = {
|
||||
"infrastructure/auto-deploy": None,
|
||||
"infrastructure/backups": None,
|
||||
"infrastructure/dns": "service:dns",
|
||||
"infrastructure/homelab-context": "service:homelab_mcp",
|
||||
"infrastructure/homelab-context": "service:homelab-mcp",
|
||||
"infrastructure/ingress": "service:caddy",
|
||||
"infrastructure/media-permissions": "service:jellyfin",
|
||||
"infrastructure/mesh": None,
|
||||
@@ -52,7 +52,7 @@ PATH_TO_ENTITY = {
|
||||
"infrastructure/network": None,
|
||||
"infrastructure/ssh-access": None,
|
||||
"infrastructure/topology": None,
|
||||
"infrastructure/vps-hardening": "standalone-server:netbird-vps",
|
||||
"infrastructure/vps-hardening": "host:netbird-vps",
|
||||
}
|
||||
|
||||
def parse_page(path):
|
||||
@@ -157,15 +157,8 @@ def parse_page(path):
|
||||
tags.append('infrastructure')
|
||||
|
||||
# Determine slug from relative path
|
||||
rel = str(path.relative_to(REPO))
|
||||
if rel.startswith('knowledge/wiki/'):
|
||||
slug_rel = rel[len('knowledge/wiki/'):]
|
||||
elif rel.startswith('knowledge/sources/investigations/'):
|
||||
slug_rel = rel[len('knowledge/sources/'):]
|
||||
else:
|
||||
slug_rel = rel
|
||||
|
||||
slug = slug_rel.replace('.md', '')
|
||||
rel = str(path.relative_to(WIKI))
|
||||
slug = rel.replace('.md', '')
|
||||
|
||||
# Entity mapping
|
||||
entity_slug = PATH_TO_ENTITY.get(slug, None)
|
||||
@@ -226,15 +219,15 @@ def parse_investigation(path):
|
||||
(r'\bartifacto\b', 'service:artifacto'),
|
||||
(r'\barriman\b', 'lxc:arriman'),
|
||||
(r'\btrmnl\b', 'service:trmnl'),
|
||||
(r'\bmac-mini\b', 'workstation:mac-mini'),
|
||||
(r'\bhubris\b', 'proxmox-host:hubris'),
|
||||
(r'\bstrong\b', 'proxmox-host:strong'),
|
||||
(r'\bmac-mini\b', 'ws:mac-mini'),
|
||||
(r'\bhubris\b', 'host:hubris'),
|
||||
(r'\bstrong\b', 'host:strong'),
|
||||
]
|
||||
for pattern, slug in entity_patterns:
|
||||
if re.search(pattern, text, re.IGNORECASE):
|
||||
about_slugs.append(slug)
|
||||
|
||||
rel = str(path.relative_to(SOURCES))
|
||||
rel = str(path.relative_to(WIKI))
|
||||
slug = rel.replace('.md', '')
|
||||
|
||||
return {
|
||||
@@ -257,7 +250,9 @@ def main():
|
||||
# Container pages
|
||||
containers_dir = WIKI / "containers"
|
||||
for f in sorted(containers_dir.glob("*.md")):
|
||||
if 'index' in f.name or 'archive' in str(f):
|
||||
if 'index' in f.name:
|
||||
continue
|
||||
if f.parent.name == 'archive':
|
||||
continue
|
||||
result = parse_page(f)
|
||||
if result and result['title']:
|
||||
@@ -297,7 +292,7 @@ def main():
|
||||
# Investigation pages
|
||||
inv_dir = SOURCES / "investigations"
|
||||
for f in sorted(inv_dir.glob("*.md")):
|
||||
if 'index' in f.name or 'archive' in str(f):
|
||||
if 'index' in f.name:
|
||||
continue
|
||||
result = parse_investigation(f)
|
||||
if result and result['title']:
|
||||
|
||||
Reference in New Issue
Block a user