Thank you for your interest in contributing to Tyk CLI! This guide will help you get started with contributing to the project.
- Fork the repository on GitHub
- Clone your fork locally:
git clone https://github.com/your-username/tyk-cli.git cd tyk-cli - Install dependencies:
go mod download
- Make your changes
- Test your changes:
go test ./... - Submit a pull request
- Go 1.21+ - Installation guide
- Git - For version control
- Make (optional) - For using Makefile commands
# Clone the repository
git clone https://github.com/sedkis/tyk-cli.git
cd tyk-cli
# Install dependencies
go mod download
# Build the CLI
go build -o tyk .
# Run tests
go test ./...
# Run with coverage
go test -coverprofile=coverage.out ./...
go tool cover -html=coverage.out
# Format code
go fmt ./...
# Run linter (if golangci-lint is installed)
golangci-lint run# Build the project
make build
# Run tests
make test
# Run tests with coverage
make test-coverage
# Format and lint code
make fmt
make lint
# Clean build artifacts
make cleantyk-cli/
βββ cmd/ # CLI commands and subcommands
β βββ root.go # Root command and global flags
β βββ init.go # Interactive setup wizard
β βββ api/ # API management commands
β β βββ apply.go # Apply API configurations
β β βββ create.go # Create new APIs
β β βββ get.go # Get API details
β β βββ update.go # Update existing APIs
β β βββ delete.go # Delete APIs
β βββ config/ # Configuration commands
β βββ list.go # List environments
β βββ use.go # Switch environments
β βββ current.go # Show current environment
βββ internal/ # Internal packages
β βββ config/ # Configuration management
β β βββ config.go # Config file operations
β β βββ environment.go # Environment management
β βββ client/ # HTTP client for Tyk Dashboard API
β β βββ client.go # Base client implementation
β β βββ api.go # API-specific operations
β βββ util/ # Utilities and helpers
β βββ output.go # Output formatting
β βββ validation.go # Input validation
βββ pkg/ # Public packages (if any)
βββ test/ # Integration tests
β βββ fixtures/ # Test fixtures and sample data
β βββ integration/ # Integration test suites
βββ docs/ # Documentation
βββ scripts/ # Build and deployment scripts
We welcome various types of contributions:
When filing a bug report, please include:
- Clear description of the issue
- Steps to reproduce the problem
- Expected vs actual behavior
- Environment details (OS, Go version, CLI version)
- Relevant logs or error messages
Use the bug report template:
**Describe the bug**
A clear description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
1. Run command '...'
2. See error
**Expected behavior**
What you expected to happen.
**Environment:**
- OS: [e.g., macOS 13.0]
- Go version: [e.g., 1.21.0]
- CLI version: [e.g., v1.0.0]
**Additional context**
Any other context about the problem.For new features, please:
- Check existing issues to avoid duplicates
- Describe the use case and why it's needed
- Propose an implementation approach (optional)
- Consider breaking changes and compatibility
Documentation improvements are always welcome:
- Fix typos or unclear explanations
- Add missing documentation
- Improve examples
- Update outdated information
When contributing code:
- Follow Go conventions and idioms
- Write tests for new functionality
- Update documentation if needed
- Keep changes focused (one feature/fix per PR)
- Follow Go standards: Use
go fmtandgolangci-lint - Use meaningful names: Variables, functions, and packages should have descriptive names
- Add comments: Especially for exported functions and complex logic
- Handle errors: Always check and handle errors appropriately
- Write unit tests for new functions
- Add integration tests for new commands
- Maintain test coverage above 80%
- Use table-driven tests where appropriate
Example test structure:
func TestSomeFunction(t *testing.T) {
tests := []struct {
name string
input string
expected string
wantErr bool
}{
{"valid input", "test", "expected", false},
{"invalid input", "", "", true},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
result, err := SomeFunction(tt.input)
if (err != nil) != tt.wantErr {
t.Errorf("SomeFunction() error = %v, wantErr %v", err, tt.wantErr)
return
}
if result != tt.expected {
t.Errorf("SomeFunction() = %v, want %v", result, tt.expected)
}
})
}
}We follow conventional commits:
- feat: New features
- fix: Bug fixes
- docs: Documentation changes
- style: Code style changes (no functional changes)
- refactor: Code refactoring
- test: Adding or fixing tests
- chore: Maintenance tasks
Examples:
feat: add api versioning support
fix: resolve config file permission issue
docs: update installation instructions
test: add integration tests for api create command
-
Create a branch from
main:git checkout -b feature/your-feature-name
-
Make your changes with clear, focused commits
-
Run tests and ensure they pass:
go test ./... -
Run linter and fix any issues:
golangci-lint run
-
Update documentation if needed
-
Push your branch to your fork:
git push origin feature/your-feature-name
-
Create a pull request on GitHub
-
Fill out the PR template completely:
## Description
Brief description of changes
## Type of Change
- [ ] Bug fix
- [ ] New feature
- [ ] Documentation update
- [ ] Refactoring
## Testing
- [ ] Tests pass locally
- [ ] Added new tests if needed
- [ ] Manual testing completed
## Checklist
- [ ] Code follows project guidelines
- [ ] Self-review completed
- [ ] Documentation updated
- [ ] No breaking changes (or documented)- Automated checks must pass (tests, linting)
- Code review by maintainers
- Address feedback promptly
- Maintainer approval required for merge
# Run all tests
go test ./...
# Run tests with coverage
go test -coverprofile=coverage.out ./...
go tool cover -html=coverage.out
# Run specific package tests
go test ./internal/config
# Run with verbose output
go test -v ./...Integration tests require a running Tyk Dashboard:
# Set up test environment
export TYK_DASH_URL=http://localhost:3000
export TYK_AUTH_TOKEN=your-test-token
export TYK_ORG_ID=your-test-org
# Run integration tests
go test ./test/integration/...We aim for >80% test coverage. Check coverage with:
go test -coverprofile=coverage.out ./...
go tool cover -func=coverage.out- Use clear, concise language
- Include practical examples
- Test all code examples
- Follow existing documentation style
- API Reference: Complete command documentation
- Guides: Step-by-step tutorials
- Examples: Real-world usage scenarios
- Contributing: This guide
Documentation is built using Jekyll for GitHub Pages:
# Install Jekyll (one time)
gem install bundler jekyll
# Navigate to docs directory
cd docs
# Install dependencies
bundle install
# Serve locally
bundle exec jekyll serveContributors are recognized in:
- Release notes for significant contributions
- Contributors section in README
- GitHub contributors page
If you need help:
- GitHub Issues: Ask questions or report problems
- GitHub Discussions: Community discussions and ideas
- Tyk Community Forum: General Tyk-related questions
For maintainers:
- Update version in relevant files
- Create release notes
- Tag release:
git tag -a v1.2.3 -m "Release v1.2.3" - Push tag:
git push origin v1.2.3 - GitHub Actions handles the rest
By contributing to Tyk CLI, you agree that your contributions will be licensed under the MIT License.
Thank you for contributing to Tyk CLI! Your efforts help make API management easier for everyone. π