Add upgrade-availability hint#2590
Draft
dgageot wants to merge 8 commits intodocker:mainfrom
Draft
Conversation
Adds a best-effort GitHub-release check (cached for 24h, opt-out via DOCKER_AGENT_DISABLE_VERSION_CHECK=1) that surfaces an upgrade hint in the version subcommand and the TUI status bar.
Drop the unused synchronous Latest() function, replace the Result struct with a plain LatestCached(current) string that returns "" when no upgrade is known, and remove the redundant cache mutex and write+rename dance — readCache already tolerates partial reads. Also expose a SeedCacheForTest helper so external tests no longer reach into the JSON layout.
- Use custom http.Client with 5s timeout instead of DefaultClient - Limit redirects to 3 to prevent SSRF and redirect loops - Add test for redirect limit enforcement - Add test for concurrent RefreshAsync calls to verify thread safety
- Use errors.New instead of fmt.Errorf for static strings - Use integer range loop (Go 1.22+) - Fix formatting
Write to a temporary file and rename atomically to prevent cache corruption when multiple docker agent processes run concurrently.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2467.
Surfaces a hint when a newer GitHub release of docker-agent is available, in
both the TUI status bar and the `version` subcommand.
How it works
`https://api.github.com/repos/docker/docker-agent/releases/latest\` in a
background goroutine and caches the result on disk for 24h
(`/version-check.json`).
`cmd/root/run.go`). All other subcommands and the TUI itself read the
cache via `LatestCached` and never touch the network.
`http.DefaultClient`.
`docker agent run` processes can't corrupt it.
swallowed: the user simply does not see a hint.
Where the hint shows up
`docker agent version`:
```
docker agent version v1.0.0
Commit: abc123
A newer version is available: v1.53.0
Release notes: https://github.com/docker/docker-agent/releases/tag/v1.53.0
```
TUI status bar (right side of the title):
```
docker agent v1.0.0 (update available: v1.53.0)
```
Opt-out
Set `DOCKER_AGENT_DISABLE_VERSION_CHECK=1` (or `true`/`yes`/`on`)
to fully disable the feature — both the network call and the cached hint.
The env var is set unconditionally in the runtime stage of the Dockerfile,
since container images are immutable and can't self-upgrade.
The new env var is documented in `docs/configuration/overview/index.md`.
Tests
(via `httptest`), redirect-limit enforcement, opt-out env var, and the
TUI title helper.
encapsulated.
`golangci-lint run ./...` all pass.