cmd/tailscale/cli: clean up how optional commands get registered
Some checks are pending
checklocks / checklocks (push) Waiting to run
CodeQL / Analyze (go) (push) Waiting to run
Dockerfile build / deploy (push) Waiting to run
CI / race-root-integration (1/4) (push) Waiting to run
CI / race-root-integration (2/4) (push) Waiting to run
CI / race-root-integration (3/4) (push) Waiting to run
CI / race-root-integration (4/4) (push) Waiting to run
CI / test (-coverprofile=/tmp/coverage.out, amd64) (push) Waiting to run
CI / test (-race, amd64, 1/3) (push) Waiting to run
CI / test (-race, amd64, 2/3) (push) Waiting to run
CI / test (-race, amd64, 3/3) (push) Waiting to run
CI / test (386) (push) Waiting to run
CI / windows (push) Waiting to run
CI / privileged (push) Waiting to run
CI / vm (push) Waiting to run
CI / race-build (push) Waiting to run
CI / cross (386, linux) (push) Waiting to run
CI / cross (amd64, darwin) (push) Waiting to run
CI / cross (amd64, freebsd) (push) Waiting to run
CI / cross (amd64, openbsd) (push) Waiting to run
CI / cross (amd64, windows) (push) Waiting to run
CI / cross (arm, 5, linux) (push) Waiting to run
CI / cross (arm, 7, linux) (push) Waiting to run
CI / cross (arm64, darwin) (push) Waiting to run
CI / cross (arm64, linux) (push) Waiting to run
CI / cross (arm64, windows) (push) Waiting to run
CI / cross (loong64, linux) (push) Waiting to run
CI / ios (push) Waiting to run
CI / crossmin (amd64, illumos) (push) Waiting to run
CI / crossmin (amd64, plan9) (push) Waiting to run
CI / crossmin (amd64, solaris) (push) Waiting to run
CI / crossmin (ppc64, aix) (push) Waiting to run
CI / android (push) Waiting to run
CI / wasm (push) Waiting to run
CI / tailscale_go (push) Waiting to run
CI / fuzz (push) Waiting to run
CI / depaware (push) Waiting to run
CI / go_generate (push) Waiting to run
CI / go_mod_tidy (push) Waiting to run
CI / licenses (push) Waiting to run
CI / staticcheck (386, windows) (push) Waiting to run
CI / staticcheck (amd64, darwin) (push) Waiting to run
CI / staticcheck (amd64, linux) (push) Waiting to run
CI / staticcheck (amd64, windows) (push) Waiting to run
CI / notify_slack (push) Blocked by required conditions
CI / check_mergeability (push) Blocked by required conditions
Some checks are pending
checklocks / checklocks (push) Waiting to run
CodeQL / Analyze (go) (push) Waiting to run
Dockerfile build / deploy (push) Waiting to run
CI / race-root-integration (1/4) (push) Waiting to run
CI / race-root-integration (2/4) (push) Waiting to run
CI / race-root-integration (3/4) (push) Waiting to run
CI / race-root-integration (4/4) (push) Waiting to run
CI / test (-coverprofile=/tmp/coverage.out, amd64) (push) Waiting to run
CI / test (-race, amd64, 1/3) (push) Waiting to run
CI / test (-race, amd64, 2/3) (push) Waiting to run
CI / test (-race, amd64, 3/3) (push) Waiting to run
CI / test (386) (push) Waiting to run
CI / windows (push) Waiting to run
CI / privileged (push) Waiting to run
CI / vm (push) Waiting to run
CI / race-build (push) Waiting to run
CI / cross (386, linux) (push) Waiting to run
CI / cross (amd64, darwin) (push) Waiting to run
CI / cross (amd64, freebsd) (push) Waiting to run
CI / cross (amd64, openbsd) (push) Waiting to run
CI / cross (amd64, windows) (push) Waiting to run
CI / cross (arm, 5, linux) (push) Waiting to run
CI / cross (arm, 7, linux) (push) Waiting to run
CI / cross (arm64, darwin) (push) Waiting to run
CI / cross (arm64, linux) (push) Waiting to run
CI / cross (arm64, windows) (push) Waiting to run
CI / cross (loong64, linux) (push) Waiting to run
CI / ios (push) Waiting to run
CI / crossmin (amd64, illumos) (push) Waiting to run
CI / crossmin (amd64, plan9) (push) Waiting to run
CI / crossmin (amd64, solaris) (push) Waiting to run
CI / crossmin (ppc64, aix) (push) Waiting to run
CI / android (push) Waiting to run
CI / wasm (push) Waiting to run
CI / tailscale_go (push) Waiting to run
CI / fuzz (push) Waiting to run
CI / depaware (push) Waiting to run
CI / go_generate (push) Waiting to run
CI / go_mod_tidy (push) Waiting to run
CI / licenses (push) Waiting to run
CI / staticcheck (386, windows) (push) Waiting to run
CI / staticcheck (amd64, darwin) (push) Waiting to run
CI / staticcheck (amd64, linux) (push) Waiting to run
CI / staticcheck (amd64, windows) (push) Waiting to run
CI / notify_slack (push) Blocked by required conditions
CI / check_mergeability (push) Blocked by required conditions
Both @agottardo and I tripped over this today. Updates #cleanup Change-Id: I64380a03bfc952b9887b1512dbcadf26499ff1cd Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
parent
8b9d5fd6bc
commit
e12b2a7267
@ -21,7 +21,11 @@
|
|||||||
|
|
||||||
// TODO(naman): This flag may move to set.go or serve_v2.go after the WIPCode
|
// TODO(naman): This flag may move to set.go or serve_v2.go after the WIPCode
|
||||||
// envknob is not needed.
|
// envknob is not needed.
|
||||||
var advertiseCmd = &ffcli.Command{
|
func advertiseCmd() *ffcli.Command {
|
||||||
|
if !envknob.UseWIPCode() {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return &ffcli.Command{
|
||||||
Name: "advertise",
|
Name: "advertise",
|
||||||
ShortUsage: "tailscale advertise --services=<services>",
|
ShortUsage: "tailscale advertise --services=<services>",
|
||||||
ShortHelp: "Advertise this node as a destination for a service",
|
ShortHelp: "Advertise this node as a destination for a service",
|
||||||
@ -31,13 +35,7 @@
|
|||||||
fs.StringVar(&advertiseArgs.services, "services", "", "comma-separated services to advertise; each must start with \"svc:\" (e.g. \"svc:idp,svc:nas,svc:database\")")
|
fs.StringVar(&advertiseArgs.services, "services", "", "comma-separated services to advertise; each must start with \"svc:\" (e.g. \"svc:idp,svc:nas,svc:database\")")
|
||||||
return fs
|
return fs
|
||||||
})(),
|
})(),
|
||||||
}
|
|
||||||
|
|
||||||
func maybeAdvertiseCmd() []*ffcli.Command {
|
|
||||||
if !envknob.UseWIPCode() {
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
return []*ffcli.Command{advertiseCmd}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func runAdvertise(ctx context.Context, args []string) error {
|
func runAdvertise(ctx context.Context, args []string) error {
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
"tailscale.com/cmd/tailscale/cli/ffcomplete"
|
"tailscale.com/cmd/tailscale/cli/ffcomplete"
|
||||||
"tailscale.com/envknob"
|
"tailscale.com/envknob"
|
||||||
"tailscale.com/paths"
|
"tailscale.com/paths"
|
||||||
|
"tailscale.com/util/slicesx"
|
||||||
"tailscale.com/version/distro"
|
"tailscale.com/version/distro"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -182,7 +183,7 @@ func newRootCmd() *ffcli.Command {
|
|||||||
This CLI is still under active development. Commands and flags will
|
This CLI is still under active development. Commands and flags will
|
||||||
change in the future.
|
change in the future.
|
||||||
`),
|
`),
|
||||||
Subcommands: append([]*ffcli.Command{
|
Subcommands: nonNilCmds(
|
||||||
upCmd,
|
upCmd,
|
||||||
downCmd,
|
downCmd,
|
||||||
setCmd,
|
setCmd,
|
||||||
@ -214,7 +215,8 @@ func newRootCmd() *ffcli.Command {
|
|||||||
debugCmd,
|
debugCmd,
|
||||||
driveCmd,
|
driveCmd,
|
||||||
idTokenCmd,
|
idTokenCmd,
|
||||||
}, maybeAdvertiseCmd()...),
|
advertiseCmd(),
|
||||||
|
),
|
||||||
FlagSet: rootfs,
|
FlagSet: rootfs,
|
||||||
Exec: func(ctx context.Context, args []string) error {
|
Exec: func(ctx context.Context, args []string) error {
|
||||||
if len(args) > 0 {
|
if len(args) > 0 {
|
||||||
@ -239,6 +241,10 @@ func newRootCmd() *ffcli.Command {
|
|||||||
return rootCmd
|
return rootCmd
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func nonNilCmds(cmds ...*ffcli.Command) []*ffcli.Command {
|
||||||
|
return slicesx.Filter(cmds[:0], cmds, func(c *ffcli.Command) bool { return c != nil })
|
||||||
|
}
|
||||||
|
|
||||||
func fatalf(format string, a ...any) {
|
func fatalf(format string, a ...any) {
|
||||||
if Fatalf != nil {
|
if Fatalf != nil {
|
||||||
Fatalf(format, a...)
|
Fatalf(format, a...)
|
||||||
|
Loading…
Reference in New Issue
Block a user