🎯 Objective
Complete and enhance the migration documentation for users transitioning from template-based to programmatic markdown generation in v2.0. This task builds upon existing migration guides to provide comprehensive support for custom template users.
📋 Context
Related Work
Parent Issue : Phase 3: Migrate Template Functions to Type-Safe Go Methods for Performance & Maintainability #86 - Phase 3: Port Template Functions to Go Methods
Existing Documentation :
docs/migration.md - General migration guide with performance benefits and basic steps
docs/template-function-migration.md - Function mapping reference with migration status
Breaking Change : Template deprecation planned for v3.0
Current Status : Core MarkdownBuilder methods implemented, need user-facing documentation completion
Why This Matters
Custom template users need clear, actionable guidance to:
Understand migration urgency and timeline (template support ending v3.0)
Map their custom template functions to new Go methods
Validate migration success before production deployment
Contribute custom functions back to the project
Without this : Users may abandon opnDossier or face breaking changes without preparation.
🔧 Proposed Solution
1. Enhance Migration Guide (docs/migration-guide.md)
Additions to existing docs/migration.md:
A. Clear Deprecation Timeline
## ⚠️ Deprecation Timeline
- ** v2.0** (Current): Template mode available via ` --use-template ` flag
- ** v2.1-v2.5** : Template mode deprecated, warnings issued
- ** v3.0** : Template mode removed entirely
** Action Required** : Migrate custom templates by v2.5 (estimated Q2 2025)
B. Custom Template User Quick Start
## For Custom Template Users
### Step 1: Assessment
Run the migration validator to identify custom functions:
\`\`\` bash
./scripts/validate-migration.sh --analyze ./your-templates/
\`\`\`
### Step 2: Map Functions
Use the function mapping table to find equivalents:
- ` {{ getRiskLevel .severity }} ` → ` builder.AssessRiskLevel(severity) `
- See full mapping in [ template-function-migration.md] ( ./template-function-migration.md )
### Step 3: Choose Migration Path
** Option A** : Continue with templates (temporary)
\`\`\` bash
opndossier convert -i config.xml -o report.md --use-template
\`\`\`
** Option B** : Migrate to programmatic (recommended)
- Create custom builder extending MarkdownBuilder
- Port template logic to Go methods
- See examples below
C. Real-World Migration Examples
// Example 1: Custom Risk Assessment Section
type SecurityBuilder struct {
* converter.MarkdownBuilder
}
func (b * SecurityBuilder ) WriteRiskAnalysis (doc * model.OpnSenseDocument ) {
b .WriteHeader (2 , "🔒 Security Risk Analysis" )
// Use inherited MarkdownBuilder methods
firewallRisk := b .AssessRiskLevel (doc .Firewall .Severity )
natRisk := b .AssessNATRuleRisk (doc .NAT .Rules )
b .WriteTable ([]string {"Component" , "Risk Level" , "Action" }, [][]string {
{"Firewall" , firewallRisk , "Review rules" },
{"NAT" , natRisk , "Audit configuration" },
})
}
// Example 2: Custom Compliance Report
func (b * SecurityBuilder ) WriteComplianceSection (doc * model.OpnSenseDocument ) {
b .WriteHeader (2 , "📊 Compliance Status" )
for _ , rule := range doc .Firewall .Rules {
compliance := b .AssessFirewallRuleCompliance (rule )
if compliance .IsFailing () {
b .WriteListItem (fmt .Sprintf ("❌ %s: %s" , rule .Description , compliance .Recommendation ))
}
}
}
2. Create Migration Validator Script (scripts/validate-migration.sh)
Enhanced version with actual validation:
#! /bin/bash
# Migration Validation Tool v2.0
set -e
TEMPLATE_DIR=" ${1:- .} "
SAMPLE_CONFIG=" ${2:- sample.xml} "
echo " ╔════════════════════════════════════════════╗"
echo " ║ opnDossier Migration Validation Tool ║"
echo " ╚════════════════════════════════════════════╝"
echo " "
# Check prerequisites
command -v opndossier > /dev/null 2>&1 || {
echo " ❌ opndossier not found. Install with: go install github.com/EvilBit-Labs/opnDossier@latest"
exit 1
}
# Detect custom templates
if [ -d " $TEMPLATE_DIR /templates" ]; then
echo " ✅ Custom templates detected: $TEMPLATE_DIR /templates"
# Extract custom functions
echo " "
echo " 📋 Custom template functions found:"
grep -rho ' {{ *\([a-zA-Z_][a-zA-Z0-9_]*\)' " $TEMPLATE_DIR /templates" | \
sort -u | \
grep -v -E ' (if|range|end|define|template|with|block)' | \
sed ' s/{{ */ - /' || echo " (none detected)"
# Check for unmigrated functions
echo " "
echo " ⚠️ Checking for functions without Go equivalents..."
# Add validation logic here
else
echo " ℹ️ No custom templates found in $TEMPLATE_DIR "
fi
# Generate comparison reports if sample config exists
if [ -f " $SAMPLE_CONFIG " ]; then
echo " "
echo " 🔄 Generating comparison reports..."
# Template mode
if opndossier convert -i " $SAMPLE_CONFIG " -o /tmp/report-template.md --use-template 2> /dev/null; then
echo " ✅ Template mode: /tmp/report-template.md"
else
echo " ⚠️ Template mode failed (expected if no templates)"
fi
# Programmatic mode
if opndossier convert -i " $SAMPLE_CONFIG " -o /tmp/report-programmatic.md 2> /dev/null; then
echo " ✅ Programmatic mode: /tmp/report-programmatic.md"
else
echo " ❌ Programmatic mode failed"
exit 1
fi
# Compare outputs
if [ -f /tmp/report-template.md ] && [ -f /tmp/report-programmatic.md ]; then
echo " "
echo " 📊 Output comparison:"
TEMPLATE_LINES=$( wc -l < /tmp/report-template.md)
PROGRAMMATIC_LINES=$( wc -l < /tmp/report-programmatic.md)
echo " Template mode: $TEMPLATE_LINES lines"
echo " Programmatic mode: $PROGRAMMATIC_LINES lines"
echo " Difference: $(( PROGRAMMATIC_LINES - TEMPLATE_LINES)) lines"
# Generate detailed diff
diff -u /tmp/report-template.md /tmp/report-programmatic.md > /tmp/migration-diff.txt 2>&1 || true
echo " Detailed diff saved to: /tmp/migration-diff.txt"
fi
else
echo " ℹ️ No sample config provided, skipping comparison"
fi
echo " "
echo " ✅ Validation complete!"
echo " "
echo " Next Steps:"
echo " 1. Review function mappings: docs/template-function-migration.md"
echo " 2. Check detailed diff: /tmp/migration-diff.txt"
echo " 3. Follow migration guide: docs/migration.md"
3. Add Contributing Guide Section
Append to docs/migration.md:
## 🤝 Contributing Custom Functions
If you've created useful custom functions, contribute them back!
### Contribution Process
1 . ** Implement as MarkdownBuilder method** :
\`\`\` go
// File: internal/converter/markdown_custom.go
func (b * MarkdownBuilder) MyCustomFunction(param string) string {
// Implementation with proper error handling
return result
}
\`\`\`
2 . ** Add comprehensive tests** :
\`\`\` go
// File: internal/converter/markdown_custom_test.go
func TestMarkdownBuilder_MyCustomFunction(t * testing.T) {
// Test cases including edge cases
}
\`\`\`
3 . ** Document in migration guide** :
- Add to function mapping table
- Provide usage example
- Explain migration path from template
4 . ** Submit PR** with:
- Clear description of use case
- Before/after examples
- Test coverage report
✅ Acceptance Criteria
Documentation
Tooling
Testing
🔗 References
📅 Timeline
🎯 Objective
Complete and enhance the migration documentation for users transitioning from template-based to programmatic markdown generation in v2.0. This task builds upon existing migration guides to provide comprehensive support for custom template users.
📋 Context
Related Work
docs/migration.md- General migration guide with performance benefits and basic stepsdocs/template-function-migration.md- Function mapping reference with migration statusWhy This Matters
Custom template users need clear, actionable guidance to:
Without this: Users may abandon opnDossier or face breaking changes without preparation.
🔧 Proposed Solution
1. Enhance Migration Guide (
docs/migration-guide.md)Additions to existing docs/migration.md:
A. Clear Deprecation Timeline
B. Custom Template User Quick Start
C. Real-World Migration Examples
2. Create Migration Validator Script (
scripts/validate-migration.sh)Enhanced version with actual validation:
3. Add Contributing Guide Section
Append to
docs/migration.md:✅ Acceptance Criteria
Documentation
docs/migration.mdenhanced with:docs/template-function-migration.mdupdated with all current MarkdownBuilder methodsTooling
scripts/validate-migration.shimplemented with:Testing
🔗 References
📅 Timeline