provisioning-core/nulib/domain/workspace/verify.nu

130 lines
4.6 KiB
Text
Raw Normal View History

# Workspace Configuration Verification Script
# Confirms that config.defaults.toml is NOT loaded at runtime
export def verify-workspace-architecture [] {
print "🔍 Verifying Workspace Configuration Architecture"
print "=================================================="
print ""
mut all_checks_passed = true
# Check 1: Templates directory exists
print "📋 Check 1: Template directory exists"
let templates_dir = ($env.PROVISIONING | path join "config/templates")
if ($templates_dir | path exists) {
print " ✅ Templates directory found: $templates_dir"
} else {
print " ❌ Templates directory NOT found"
$all_checks_passed = false
}
# Check 2: All template files exist
print "\n📋 Check 2: All template files exist"
let required_templates = [
"workspace-provisioning.yaml.template"
"provider-aws.toml.template"
"provider-local.toml.template"
"provider-upcloud.toml.template"
"kms.toml.template"
"user-context.yaml.template"
"README.md"
]
for template in $required_templates {
let template_path = ($templates_dir | path join $template)
if ($template_path | path exists) {
print $" ✅ ($template)"
} else {
print $" ❌ ($template) NOT found"
$all_checks_passed = false
}
}
# Check 3: Workspace init module exists
print "\n📋 Check 3: Workspace init module exists"
let init_module = ($env.PROVISIONING | path join "core/nulib/lib_provisioning/workspace/init.nu")
if ($init_module | path exists) {
print " ✅ Workspace init module found"
} else {
print " ❌ Workspace init module NOT found"
$all_checks_passed = false
}
# Check 4: Config loader has been updated
print "\n📋 Check 4: Config loader has new workspace functions"
let loader_module = ($env.PROVISIONING | path join "core/nulib/lib_provisioning/config/loader.nu")
if ($loader_module | path exists) {
let loader_content = (open $loader_module)
if ($loader_content | str contains "get-active-workspace") {
print " ✅ get-active-workspace() function exists"
} else {
print " ❌ get-active-workspace() function NOT found"
$all_checks_passed = false
}
if ($loader_content | str contains "def get-defaults-config-path") {
print " ❌ OLD get-defaults-config-path() function still exists (should be removed)"
$all_checks_passed = false
} else {
print " ✅ OLD get-defaults-config-path() function has been removed"
}
if ($loader_content | str contains "workspace/{name}/config/provisioning.yaml") {
print " ✅ New workspace hierarchy documented in code"
} else {
print " ⚠️ New workspace hierarchy comment not found"
}
if ($loader_content | str contains "from yaml") {
print " ✅ YAML format support added"
} else {
print " ❌ YAML format support NOT found"
$all_checks_passed = false
}
} else {
print " ❌ Config loader module NOT found"
$all_checks_passed = false
}
# Check 5: Documentation exists
print "\n📋 Check 5: Documentation exists"
let docs = [
($env.HOME | path join "Development/provisioning/docs/configuration/workspace-config-architecture.md")
($env.HOME | path join "Development/provisioning/docs/configuration/WORKSPACE_CONFIG_IMPLEMENTATION_SUMMARY.md")
]
for doc in $docs {
if ($doc | path exists) {
print $" ✅ ($doc | path basename)"
} else {
print $" ❌ ($doc | path basename) NOT found"
$all_checks_passed = false
}
}
# Check 6: config.defaults.toml still exists (as template)
print "\n📋 Check 6: config.defaults.toml exists as template"
let defaults_file = ($env.PROVISIONING | path join "config/config.defaults.toml")
if ($defaults_file | path exists) {
print " ✅ config.defaults.toml exists (as template only)"
print " This file is NEVER loaded at runtime"
} else {
print " ⚠️ config.defaults.toml not found (should exist as template reference)"
}
print "\n" + "=" * 50
if $all_checks_passed {
print "✅ All critical checks passed!"
} else {
print "❌ Some checks failed!"
print "Please review the failures above and fix the issues."
}
$all_checks_passed
}
export def main [] {
verify-workspace-architecture
}