fleet/docs/Contributing/workflows/upgrading-go-version.md

3.8 KiB

Upgrading the Go version used to build Fleet

Updating Go locally

The Go documentation doesn't include explicit instructions on upgrading versions. Some consider it a best practice to completely uninstall the current version before installing a new one. If you used a package manager like Homebrew to install Go, you can upgrade it using brew upgrade. You can also install multiple versions by following the Manage Go Installations guide in the Go docs. This is a good way to keep your previous version around for A/B testing.

If you use the golangci-lint linter in your local development, you'll need to recompile it using the new Go version:

go install github.com/golangci/golangci-lint/cmd/golangci-lint@<your golangci-lint version>

See the "Go linter" section below about upgrading the Go linter version.

Files to update

Go.mod

Update the Go version in the main go.mod file in Fleet to the new version.

Also update the version in the go.mod files of compiled tools including:

Do a search for go.mod files to find others that may need updating!

Go Linter

The golangci-lint linter used in the golangci-lint Github action needs to support the new version of Go. The linter typically keeps up with Go versions so that the latest version of golangci-lint should support the latest version of Go, but it's worth checking the changelog to see if it's time for an upgrade. If so, get the commit SHA of the version you'd like to use by finding its tag on Github, clicking on the commit link under the tag name, and copying the full SHA from the URL. Update the current go install github.com/golangci/golangci-lint/cmd/golangci-lint line in the .yml file with the new SHA, and update the comment to indicate the new version.

Update the instructions in the Testing and local development doc to reflect the new version of golangci-lint.

Docker files

Find the bullseye and alpine variants of the Docker images for the new Go version on Dockerhub. Then update any Dockerfiles to pull the new images, including:

Smoke-testing the new version locally

  1. Build fleet and fleetctl using make build.
  2. Verify that fleet serve runs, the site is accessible, and basic API/db functionality works (try creating a new team, query and policy)
  3. Verify that fleetctl works by using fleetctl get config
  4. Run make go-lint locally to find and fix any new issues.
  5. Create a draft pull request from your branch and verify that tests pass.

Updating this guide

As the Fleet project evolves, new areas may need to be touched when upgrading Go versions. Please update this guide with any new files you find that need changing (and remove any files that are no longer relevant).