cmd/tailscale: remove dep on clientupdate package if feature is omitted
We already had a featuretag for clientupdate, but the CLI wasn't using it, making the "minbox" build (minimal combined tailscaled + CLI build) larger than necessary. Updates #12614 Change-Id: Idd7546c67dece7078f25b8f2ae9886f58d599002 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
committed by
Brad Fitzpatrick
parent
569caefeb5
commit
40cd54daf7
@@ -219,6 +219,7 @@ var (
|
||||
maybeFunnelCmd,
|
||||
maybeServeCmd,
|
||||
maybeCertCmd,
|
||||
maybeUpdateCmd,
|
||||
_ func() *ffcli.Command
|
||||
)
|
||||
|
||||
@@ -270,7 +271,7 @@ change in the future.
|
||||
nilOrCall(maybeNetlockCmd),
|
||||
licensesCmd,
|
||||
exitNodeCmd(),
|
||||
updateCmd,
|
||||
nilOrCall(maybeUpdateCmd),
|
||||
whoisCmd,
|
||||
debugCmd(),
|
||||
nilOrCall(maybeDriveCmd),
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
// Copyright (c) Tailscale Inc & contributors
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
//go:build !ts_omit_clientupdate
|
||||
|
||||
package cli
|
||||
|
||||
import (
|
||||
@@ -17,6 +19,14 @@ import (
|
||||
"tailscale.com/version/distro"
|
||||
)
|
||||
|
||||
func init() {
|
||||
maybeUpdateCmd = func() *ffcli.Command { return updateCmd }
|
||||
|
||||
clientupdateLatestTailscaleVersion.Set(func() (string, error) {
|
||||
return clientupdate.LatestTailscaleVersion(clientupdate.CurrentTrack)
|
||||
})
|
||||
}
|
||||
|
||||
var updateCmd = &ffcli.Command{
|
||||
Name: "update",
|
||||
ShortUsage: "tailscale update",
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
"fmt"
|
||||
|
||||
"github.com/peterbourgon/ff/v3/ffcli"
|
||||
"tailscale.com/clientupdate"
|
||||
"tailscale.com/feature"
|
||||
"tailscale.com/ipn/ipnstate"
|
||||
"tailscale.com/version"
|
||||
)
|
||||
@@ -35,6 +35,8 @@ var versionArgs struct {
|
||||
upstream bool
|
||||
}
|
||||
|
||||
var clientupdateLatestTailscaleVersion feature.Hook[func() (string, error)]
|
||||
|
||||
func runVersion(ctx context.Context, args []string) error {
|
||||
if len(args) > 0 {
|
||||
return fmt.Errorf("too many non-flag arguments: %q", args)
|
||||
@@ -51,7 +53,11 @@ func runVersion(ctx context.Context, args []string) error {
|
||||
|
||||
var upstreamVer string
|
||||
if versionArgs.upstream {
|
||||
upstreamVer, err = clientupdate.LatestTailscaleVersion(clientupdate.CurrentTrack)
|
||||
f, ok := clientupdateLatestTailscaleVersion.GetOk()
|
||||
if !ok {
|
||||
return fmt.Errorf("fetching latest version not supported in this build")
|
||||
}
|
||||
upstreamVer, err = f()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user