Contributing Guide¶
Thank you for your interest in contributing to the OPNsense Configuration Processor! This guide will help you get started with development and understand our contribution process.
Development Environment Setup¶
Prerequisites¶
- Go 1.21 or later
- Git
- golangci-lint - Go linter (latest version recommended)
- MkDocs - Documentation generator (latest version recommended)
- Just (command runner) - optional but recommended
Getting Started¶
-
Fork the repository on GitHub
-
Clone your fork locally:
- Install dependencies:
- Run tests to ensure everything works:
Development Workflow¶
Code Organization¶
The project follows standard Go conventions:
cmd/- CLI commands and main entry pointsinternal/- Internal packages not exported to external usersconfig/- Configuration management and validationparser/- XML parsing and streaming logicmodel/- Data structures representing OPNsense configurationdocs/- Documentation (MkDocs format)testdata/- Test fixtures and sample files
Making Changes¶
- Create a feature branch:
-
Make your changes following our development standards
-
Add tests for new functionality:
- Run benchmarks if modifying parser performance:
- Run linting:
Validation Development¶
When working on configuration validation:
- Follow the patterns established in
internal/config/validator.go - Add comprehensive test cases covering both valid and invalid inputs
- Use the
ValidationErrortype for reporting validation issues - Include field paths and descriptive error messages
- See Validator Patterns for detailed guidance
Parser Development¶
When modifying XML parsing logic:
- Maintain streaming behavior to handle large files efficiently
- Ensure memory usage remains constant (O(1)) as file size increases
- Add benchmarks for performance-critical changes
- Test with both small sample files and large generated XML
- Preserve backward compatibility in the
Parserinterface
Testing¶
We maintain several types of tests:
- Unit tests: Test individual functions and methods
- Integration tests: Test complete workflows end-to-end
- Validation tests: Comprehensive coverage of validation rules
- Performance tests: Benchmarks for parser memory and speed
- Error handling tests: Verify proper error reporting
Run specific test suites:
# All tests
go test ./...
# Specific package
go test ./internal/config/
# Benchmarks only
go test -run=^$ -bench=. ./internal/parser/
# With coverage
go test -cover ./...
Pull Request Process¶
-
Before submitting:
-
Ensure all tests pass
- Run linting tools
- Update documentation if needed
-
Add changelog entry if appropriate
-
PR Description:
-
Clearly describe what changes were made
- Reference any related issues
- Include examples of new functionality
-
Note any breaking changes
-
Review process:
-
All PRs require at least one review
- CI must pass (tests, linting, benchmarks)
- Documentation updates may be requested
Coding Standards¶
Please follow our Development Standards which cover:
- Go coding conventions
- Error handling patterns
- Validation architecture
- Testing practices
- Performance guidelines
Documentation¶
- Update relevant documentation for user-facing changes
- Add inline comments for complex logic
- Update API documentation for interface changes
- Follow MkDocs formatting for documentation updates
Performance Considerations¶
This project processes potentially large XML files, so performance matters:
- Profile memory usage for parser changes
- Maintain streaming behavior rather than loading entire files
- Add benchmarks for significant algorithmic changes
- Consider memory allocation patterns
Getting Help¶
- Check existing issues and documentation first
- Open an issue for bugs or feature requests
- Ask questions in GitHub discussions
- Review the development standards and architecture documentation
License¶
By contributing, you agree that your contributions will be licensed under the same license as the project.
Thank you for contributing to making OPNsense configuration processing better!