hashicorp/consul
Tooling
The Makefile is the front door for every developer task. This page summarizes the most useful targets and the tooling that backs them.
Pinned tool versions
From Makefile:
| Tool | Version |
|---|---|
golangci-lint |
v2.11.4 |
mockery |
v3.5.2 |
buf (proto) |
v1.56.0 |
protoc-gen-go-grpc |
v1.5.1 |
mog (struct mapping) |
pinned commit |
protoc-go-inject-tag |
v1.3.0 |
protoc-gen-go-binary |
v0.1.0 |
deep-copy |
pinned commit |
copywrite |
v0.16.4 |
lint-consul-retry |
v1.4.0 |
gci (import sorter) |
v0.11.2 |
make tools installs them all into $(GOPATH)/bin. make codegen-tools installs only the generators.
Most useful Makefile targets
| Target | Purpose |
|---|---|
make dev |
Build a local-arch dev binary into ./bin/consul |
make linux |
Build a Linux binary (used by integration tests on macOS hosts) |
make dev-docker |
Build a consul-dev:latest Docker image |
make test / test-internal |
Run unit tests for the root module |
make test-all |
Walk every sub-module and run its tests |
make test-race |
Tests with the race detector |
make test-deployer |
Deployer-based integration suite (Docker, slow) |
make test-envoy-integ |
Envoy/Connect integration suite |
make test-compat-integ |
Cross-version compatibility tests |
make lint |
golangci-lint over every module |
make fmt |
gofmt + goimports over every module |
make proto |
Regenerate protobuf files (uses buf) |
make mocks |
Regenerate mocks (uses mockery) |
make codegen |
Regenerate deep-copy and other helpers |
make ui |
Build the Ember UI inside Docker |
make ui-regen |
Build the UI and check the generated assets in (used during release) |
make module-versions |
Print outdated dependencies (each module) |
make version |
Print the current Consul version (version/VERSION) |
Run make help for the full list.
Linting
golangci-lint configuration lives in .golangci.yml. The rules emphasize:
gofmt,goimports,gosimpleerrorlint(proper%wusage)bodyclose(HTTP response leaks)reviveand a small set of custom rules for HashiCorp's house style.
Sub-modules link the same configuration via symlinks (api/.golangci.yml -> ../.golangci.yml).
Pre-commit hooks
.pre-commit-config.yaml defines hooks for gofmt, goimports, golangci-lint, and copywrite header enforcement. Install pre-commit once with pre-commit install and your commits get checked locally.
Code generation
| Generator | Targets |
|---|---|
buf |
proto/, proto-public/ — make proto |
mockery |
All *_mock.go files driven by .grpcmocks.yaml |
deep-copy |
Per-package deep-copy.sh scripts (e.g., agent/structs/, agent/consul/state/, agent/proxycfg/) |
protoc-go-inject-tag |
Adds JSON tags to generated proto Go |
protoc-gen-go-binary |
Adds custom binary marshalling for proto types |
mog |
Generates struct ↔ proto conversion helpers |
The tools/ and internal/tools/ directories vendor the version-pinned tools as Go modules so they install reproducibly.
Copywrite
HashiCorp uses copywrite to enforce the BUSL header on every source file. The configuration is in .copywrite.hcl. Run:
copywrite headers --plan # show changes
copywrite headers # applyRelease tooling
.release/ contains the configuration consumed by HashiCorp's release pipeline (versions.hcl, ci.hcl, build manifests). PRs don't touch this directly; release engineers do.
Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.