GetVersion returns the running Docker Desktop version (e.g. "4.74.0") or an empty string if Docker Desktop is not running or the call fails. The lookup is bounded by a short internal timeout so a stale or missing backend socket cannot stall callers on hot paths (it is queried on every outbound buil
(ctx context.Context)
| 23 | // HTTP call on a cache miss; on a cache hit the cached value is returned |
| 24 | // without consulting ctx. |
| 25 | func GetVersion(ctx context.Context) string { |
| 26 | v, _ := versionMemoizer.Memoize("desktopVersion", func() (string, error) { |
| 27 | ctx, cancel := context.WithTimeout(ctx, 2*time.Second) |
| 28 | defer cancel() |
| 29 | |
| 30 | var info struct { |
| 31 | CurrentVersion string `json:"currentVersion"` |
| 32 | } |
| 33 | _ = ClientBackend.Get(ctx, "/update", &info) |
| 34 | return info.CurrentVersion, nil |
| 35 | }) |
| 36 | return v |
| 37 | } |
no test coverage detected