- This repository is a single-package Go module,
github.com/linode/go-metadata, for the Linode Metadata Service client. - Keep public API work in the root
metadatapackage; examples live under examples/ and integration coverage lives in the separate module under test/integration/. - Link to existing docs instead of copying them: start with README.md for setup and usage, and CONTRIBUTING.md for contribution expectations.
- Unit tests:
make unit-testorgo test -v ./ - Vet:
go vet ./... - Lint:
make lint(SKIP_DOCKER=1 make lintruns localgolangci-lint; default runs the Docker image) - Format:
make fmt(gofumpt -w -l .) ormake fix-lintfor formatter plus linter fixes - Dependency hygiene:
go mod tidyfollowed by checking for a clean diff - Remote E2E:
make test-depsthenmake e2ewithLINODE_TOKENand an SSH public key available; this provisions paid Linode infrastructure unless cleanup is enabled. - Local E2E:
make e2e-local, but only from within a Linode instance. It delegates to test/integration/Makefile and writes JUnit XML reports.
- Follow the existing functional-option pattern:
ClientOption,TokenOption, andWatcherOptionmutate private config structs. - Public client methods should accept
context.Context; tests and examples usecontext.Background()at call sites. - Endpoint files are organized by resource: instance.go, network.go, token.go, userdata.go, and sshkeys.go.
- Watchers are thin resource-specific facades over the generic polling implementation in watcher_generic.go. Preserve channel semantics:
UpdatesandErrorsare exposed channels,Startblocks until cancellation, andClosesignals the poller. - The HTTP layer uses
resty; keep client setup and token refresh behavior centralized in client.go. - Use the Go version and toolchain declared in go.mod for development tasks.
- Unit tests are co-located with root package files and should not require live Linode infrastructure.
- Integration tests use their own module in test/integration/go.mod with a local replace back to this repo.
- Prefer
httpmock/test helpers for API behavior in tests unless the change specifically targets live metadata behavior. - Be careful with E2E cleanup:
CLEANUP_TEST_LINODE_INSTANCE=trueremoves provisioned infrastructure; leaving it false can incur ongoing costs.
- CI runs lint,
go vet ./...,go mod tidy, then fails if the working tree changes. - PR titles are checked in .github/workflows/ci.yml; non-exempt PRs need a
TPT-1234:-style prefix. - The linter config in .golangci.yml enables
gosecand formattersgofumpt/goimports, with examples excluded from formatter and linter paths.