Development Getting Started
Guide for developers who want to contribute to tf2report.
Prerequisites
- Go 1.25 or later
- Git
- Make
- Terraform (for testing)
Optional:
- GVM (Go Version Manager)
- Docker (for containerized builds)
Quick Start
1. Clone Repository
git clone https://github.com/germainlefebvre4/tf2report.git
cd tf2report
2. Install Dependencies
make deps
3. Build
make build
Binary created at bin/tf2report.
4. Run Tests
make test
5. Try It Out
./bin/tf2report --plan examples/sample-plan.json
Development Workflow
Create a Feature Branch
git checkout -b feat/your-feature-name
Make Changes
Edit files following the coding guidelines in .github/instructions/.
Test Changes
# Build
make build
# Run tests
make test
# Test manually
./bin/tf2report --plan examples/sample-plan.json
Format Code
make fmt
make tidy
Commit
git add .
git commit -m "feat: add your feature description"
git push origin feat/your-feature-name
Create Pull Request
Open a pull request on GitHub with:
- Clear description of changes
- Reference to any related issues
- Test results
Available Make Targets
make # Build (default)
make build # Build binary
make test # Run tests
make fmt # Format code
make tidy # Tidy dependencies
make clean # Clean build artifacts
make install # Install system-wide
make deps # Download dependencies
make run # Build and run
make help # Show help
Project Structure
tf2report/
├── cmd/
│ └── tf2report/ # CLI entry point
│ └── main.go
├── pkg/
│ ├── config/ # Configuration
│ │ ├── loader.go
│ │ └── types.go
│ ├── report/ # Report generation
│ │ ├── formatter.go
│ │ ├── markdown.go
│ │ ├── text.go
│ │ └── json.go
│ └── terraform/ # Terraform parsing
│ ├── parser.go
│ └── types.go
├── docs/ # Documentation
├── examples/ # Example plans
├── .github/instructions/ # Coding guidelines
├── go.mod
├── Makefile
└── README.md
Running Tests
All Tests
make test
Specific Package
go test ./pkg/terraform
go test ./pkg/report
go test ./pkg/config
With Coverage
make test-coverage
Opens coverage.html in browser.
Verbose
go test -v ./...
Coding Guidelines
Follow Instructions
Read and follow:
.github/instructions/go.instructions.md- Go coding standards.github/instructions/cli.instructions.md- CLI practices.github/instructions/makefile.instructions.md- Makefile standards
Key Principles
- Idiomatic Go - Write clear, idiomatic Go code
- Error Handling - Always handle errors properly
- Documentation - Document all exported items
- Testing - Write tests for new features
- Single Package Declaration - One
packagestatement per file
Adding Features
Add Output Format
- Create
pkg/report/yourformat.go - Implement
Formatterinterface - Add to
NewFormatter()informatter.go - Add tests
- Update documentation
Add Configuration Option
- Add field to
Configinpkg/config/types.go - Set default in
loader.go - Add CLI flag in
cmd/tf2report/main.go - Update docs
Add Filter
- Add logic to
pkg/terraform/parser.go - Add config option if needed
- Wire up CLI
- Add tests
- Update docs
Testing with Examples
# Test all formats
./bin/tf2report --plan examples/sample-plan.json
./bin/tf2report --plan examples/sample-plan.json --format text
./bin/tf2report --plan examples/sample-plan.json --format json
Debugging
Verbose Mode
./bin/tf2report --plan examples/sample-plan.json --verbose
Use Debugger
# Delve debugger
dlv debug ./cmd/tf2report -- --plan examples/sample-plan.json
Documentation Updates
When changing code:
- Update relevant docs in
docs/ - Update
README.mdif needed - Follow
.github/instructions/update-docs-on-code-change.instructions.md
Continuous Integration
Tests run automatically on:
- Pull requests
- Pushes to main
- Release tags
Check .github/workflows/ for CI configuration.
Getting Help
- Read existing code
- Check
docs/directory - Review
.github/instructions/ - Open an issue on GitHub
Next Steps
- Project Structure - Detailed structure
- Building - Build instructions
- Testing - Testing guide
- API Reference - API documentation
- Contributing - Contribution guidelines