clientupdate: return OS-specific version from LatestTailscaleVersion (#11812)

We don't always have the same latest version for all platforms (like
with 1.64.2 is only Synology+Windows), so we should use the OS-specific
result from pkgs JSON response instead of the main Version field.

Updates #11795

Signed-off-by: Andrew Lytvynov <awly@tailscale.com>
This commit is contained in:
Andrew Lytvynov 2024-04-19 12:04:11 -07:00 committed by GitHub
parent bbe194c80d
commit b3fb3bf084
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1295,10 +1295,23 @@ func LatestTailscaleVersion(track string) (string, error) {
if err != nil {
return "", err
}
if latest.Version == "" {
return "", fmt.Errorf("no latest version found for %q track", track)
ver := latest.Version
switch runtime.GOOS {
case "windows":
ver = latest.MSIsVersion
case "darwin":
ver = latest.MacZipsVersion
case "linux":
ver = latest.TarballsVersion
if distro.Get() == distro.Synology {
ver = latest.SPKsVersion
}
return latest.Version, nil
}
if ver == "" {
return "", fmt.Errorf("no latest version found for OS %q on %q track", runtime.GOOS, track)
}
return ver, nil
}
type trackPackages struct {