cmd/tailscale/cli: add update notification to "up" (#9644)

Add available update message in "tailscale up" output. Also update the
message in "tailscale status" to match and mention auto-update.

Updates https://github.com/tailscale/tailscale/issues/755

Signed-off-by: Andrew Lytvynov <awly@tailscale.com>
pull/9679/head
Andrew Lytvynov 9 months ago committed by GitHub
parent dc1c7cbe3e
commit 3ee756757b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -25,6 +25,7 @@ import (
"tailscale.com/net/interfaces"
"tailscale.com/util/cmpx"
"tailscale.com/util/dnsname"
"tailscale.com/version"
)
var statusCmd = &ffcli.Command{
@ -237,7 +238,7 @@ func runStatus(ctx context.Context, args []string) error {
}
printFunnelStatus(ctx)
if cv := st.ClientVersion; cv != nil && !cv.RunningLatest && cv.LatestVersion != "" {
printf("# New Tailscale version is available: %q, run `tailscale update` to update.\n", cv.LatestVersion)
printf("# Update available: %v -> %v, run `tailscale update` or `tailscale set --auto-update` to update.\n", version.Short(), cv.LatestVersion)
}
return nil
}

@ -499,6 +499,7 @@ func runUp(ctx context.Context, cmd string, args []string, upArgs upArgsT) (retE
startLoginInteractive := func() { loginOnce.Do(func() { localClient.StartLoginInteractive(ctx) }) }
go func() {
var cv *tailcfg.ClientVersion
for {
n, err := watcher.Next()
if err != nil {
@ -509,6 +510,9 @@ func runUp(ctx context.Context, cmd string, args []string, upArgs upArgsT) (retE
msg := *n.ErrMessage
fatalf("backend error: %v\n", msg)
}
if n.ClientVersion != nil {
cv = n.ClientVersion
}
if s := n.State; s != nil {
switch *s {
case ipn.NeedsLogin:
@ -527,6 +531,11 @@ func runUp(ctx context.Context, cmd string, args []string, upArgs upArgsT) (retE
} else if printed {
// Only need to print an update if we printed the "please click" message earlier.
fmt.Fprintf(Stderr, "Success.\n")
if cv != nil && !cv.RunningLatest && cv.LatestVersion != "" {
fmt.Fprintf(Stderr, "\nUpdate available: %v -> %v\n", version.Short(), cv.LatestVersion)
fmt.Fprintln(Stderr, "Changelog: https://tailscale.com/changelog/#client")
fmt.Fprintln(Stderr, "Run `tailscale update` or `tailscale set --auto-update` to update")
}
}
select {
case running <- true:

Loading…
Cancel
Save