Thank you for your interest in contributing to Traktor! We welcome contributions from the community.
- Code of Conduct
- Getting Started
- Development Setup
- How to Contribute
- Coding Guidelines
- Testing
- Pull Request Process
- Issue Guidelines
This project adheres to a code of conduct. By participating, you are expected to uphold this code. Please be respectful and constructive in all interactions.
- Fork the repository on GitHub
- Clone your fork locally:
git clone https://github.com/YOUR-USERNAME/traktor.git cd traktor - Add upstream remote:
git remote add upstream https://github.com/GDXbsv/traktor.git
- Go 1.24.0+
- Docker 17.03+
- kubectl 1.11.3+
- Access to a Kubernetes cluster (minikube, kind, or real cluster)
- Make
# Install Go dependencies
go mod download
# Install development tools
make setup-envtest# Install CRDs
make install
# Run operator locally (connects to your kubeconfig cluster)
make run# Run tests
make test
# Run linter
make lint
# Build binary
make build
# Build Docker image
make docker-buildWe welcome many types of contributions:
- Bug Fixes - Fix issues in the codebase
- New Features - Add new functionality
- Documentation - Improve or add documentation
- Tests - Add or improve test coverage
- Examples - Add usage examples
- Performance - Optimize performance
- Refactoring - Improve code quality
- Check existing issues - Someone might already be working on it
- Open an issue first - For major changes, discuss your approach
- Keep changes focused - One feature/fix per PR
- Read the docs - Familiarize yourself with the codebase
- Follow Effective Go
- Use
gofmtfor formatting (automatically done bymake fmt) - Follow Go Code Review Comments
- Use meaningful variable names
- Write clear comments for exported functions
traktor/
├── api/v1alpha1/ # API definitions (CRDs)
├── cmd/ # Main application
├── config/ # Kubernetes manifests
├── internal/controller/ # Controller logic
├── test/ # Tests
└── docs/ # Documentation
- Files:
snake_case.go - Functions:
PascalCase(exported),camelCase(private) - Variables:
camelCase - Constants:
PascalCaseorSCREAMING_SNAKE_CASE - Types:
PascalCase
// Package controller implements the SecretsRefresh controller.
package controller
// SecretsRefreshReconciler reconciles a SecretsRefresh object.
type SecretsRefreshReconciler struct {
client.Client
Scheme *runtime.Scheme
}
// Reconcile handles the reconciliation loop.
// It restarts deployments when secrets change.
func (r *SecretsRefreshReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
// Implementation
}// Good: Return errors to caller
func (r *Reconciler) doSomething(ctx context.Context) error {
if err := r.Client.Get(ctx, key, obj); err != nil {
return fmt.Errorf("failed to get object: %w", err)
}
return nil
}
// Good: Log and handle errors appropriately
if err := r.update(ctx, obj); err != nil {
logger.Error(err, "Failed to update object")
return ctrl.Result{}, err
}- Write tests for all new features
- Maintain or improve code coverage
- Use table-driven tests where appropriate
- Test both success and failure cases
var _ = Describe("MyFeature", func() {
Context("When something happens", func() {
BeforeEach(func() {
// Setup
})
AfterEach(func() {
// Cleanup
})
It("should do the right thing", func() {
// Test logic
Expect(result).To(BeTrue())
})
})
})# Run all tests
make test
# Run specific test
go test ./internal/controller/... -v -run TestName
# Run with coverage
go test ./... -coverprofile=coverage.out
go tool cover -html=coverage.out
# Run E2E tests
make test-e2e- Unit tests should be fast and isolated
- Integration tests can use envtest
- E2E tests should test complete workflows
- Use
Eventually()for async operations - Clean up resources in
AfterEachblocks - Use unique names to avoid conflicts
git checkout -b feature/amazing-featureUse descriptive branch names:
feature/add-something- New featuresfix/issue-123- Bug fixesdocs/improve-readme- Documentationrefactor/cleanup-code- Refactoringtest/add-coverage- Tests
- Write clear, concise commit messages
- Keep commits focused and atomic
- Add tests for new functionality
- Update documentation as needed
git add .
git commit -m "feat: add amazing feature"Commit Message Format:
type(scope): subject
body (optional)
footer (optional)
Types:
feat: New featurefix: Bug fixdocs: Documentation changestest: Adding or updating testsrefactor: Code refactoringstyle: Formatting changeschore: Maintenance tasksci: CI/CD changes
Examples:
feat(controller): add namespace filtering
fix(reconcile): prevent operator self-restart
docs(readme): add quick start guide
test(controller): improve coverage for reconcile
git fetch upstream
git rebase upstream/main# Run tests
make test
# Run linter
make lint
# Verify build
make buildgit push origin feature/amazing-feature- Go to https://github.com/GDXbsv/traktor
- Click "New Pull Request"
- Select your branch
- Fill in the PR template:
## Description
Brief description of changes
## Type of Change
- [ ] Bug fix
- [ ] New feature
- [ ] Breaking change
- [ ] Documentation update
## Testing
- [ ] Unit tests added/updated
- [ ] E2E tests added/updated
- [ ] Tested locally
## Checklist
- [ ] Code follows style guidelines
- [ ] Self-review completed
- [ ] Comments added where needed
- [ ] Documentation updated
- [ ] Tests pass locally- Maintainers will review your PR
- Address feedback and comments
- Make requested changes
- Push updates to your branch
- PR will be merged once approved
Use the bug report template and include:
- Description - Clear description of the bug
- Steps to Reproduce - Detailed steps
- Expected Behavior - What should happen
- Actual Behavior - What actually happens
- Environment - OS, Kubernetes version, operator version
- Logs - Relevant logs or error messages
Example:
**Bug Description**
Deployments not restarting when secret changes
**Steps to Reproduce**
1. Install operator
2. Create SecretsRefresh with namespace selector
3. Update labeled secret
4. Deployments don't restart
**Expected Behavior**
Deployments should restart automatically
**Environment**
- Kubernetes: v1.28.0
- Operator: v0.0.1
- Platform: AWS EKS
**Logs**
[Paste relevant logs here]Include:
- Problem - What problem does this solve?
- Proposed Solution - How should it work?
- Alternatives - Other approaches considered
- Additional Context - Examples, use cases
- Check documentation first
- Search existing issues
- Be specific and clear
- Provide context
# Enable verbose logging
go run ./cmd/main.go --zap-devel
# Debug specific namespace
kubectl logs -n traktor-system deployment/traktor-controller-manager -f
# Check events
kubectl get events -n my-namespace --sort-by=.lastTimestamp# Quick iteration loop
make install # Install CRDs
make run # Run locally
# Make changes
# Ctrl+C and run again"Namespace is terminating" in tests:
- Tests now use unique namespace names to avoid this
RBAC errors:
- Make sure CRDs are installed:
make install - Check your kubeconfig has cluster-admin access
Build fails:
- Run
go mod tidy - Check Go version:
go version
- Documentation: See README.md and docs/
- Issues: Open an issue
- Discussions: Start a discussion
- Slack: Join our Slack channel (coming soon)
Contributors will be:
- Listed in release notes
- Added to CONTRIBUTORS.md
- Mentioned in relevant documentation
By contributing, you agree that your contributions will be licensed under the Apache License 2.0.
Thank you for contributing to Traktor! 🎉