cmd/tailscale/cli: remove wip-code gate for service list cmd
Updates #20166 Signed-off-by: Adriano Sela Aviles <adriano@tailscale.com>
This commit is contained in:
committed by
Adriano Sela Aviles
parent
425a916ce2
commit
d11757863d
@@ -292,7 +292,7 @@ change in the future.
|
|||||||
sshCmd,
|
sshCmd,
|
||||||
nilOrCall(maybeFunnelCmd),
|
nilOrCall(maybeFunnelCmd),
|
||||||
nilOrCall(maybeServeCmd),
|
nilOrCall(maybeServeCmd),
|
||||||
serviceCmd(),
|
serviceCmd,
|
||||||
versionCmd,
|
versionCmd,
|
||||||
nilOrCall(maybeWebCmd),
|
nilOrCall(maybeWebCmd),
|
||||||
nilOrCall(fileCmd),
|
nilOrCall(fileCmd),
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ import (
|
|||||||
"text/tabwriter"
|
"text/tabwriter"
|
||||||
|
|
||||||
"github.com/peterbourgon/ff/v3/ffcli"
|
"github.com/peterbourgon/ff/v3/ffcli"
|
||||||
"tailscale.com/envknob"
|
|
||||||
"tailscale.com/ipn/ipnstate"
|
"tailscale.com/ipn/ipnstate"
|
||||||
"tailscale.com/tailcfg"
|
"tailscale.com/tailcfg"
|
||||||
"tailscale.com/types/ipproto"
|
"tailscale.com/types/ipproto"
|
||||||
@@ -51,40 +50,32 @@ func serviceListerFromContext(ctx context.Context) serviceLister {
|
|||||||
|
|
||||||
const serviceListUsage = "tailscale service list"
|
const serviceListUsage = "tailscale service list"
|
||||||
|
|
||||||
func serviceCmd() *ffcli.Command {
|
var serviceCmd = &ffcli.Command{
|
||||||
// The service commands are still in development and gated behind the
|
Name: "service",
|
||||||
// work-in-progress knob. When it's off, serviceCmd returns nil and is
|
ShortHelp: "Interact with Tailscale Services",
|
||||||
// filtered out of the root command's subcommands by nonNilCmds.
|
ShortUsage: "tailscale service",
|
||||||
if !envknob.UseWIPCode() {
|
LongHelp: strings.TrimSpace(`
|
||||||
return nil
|
|
||||||
}
|
|
||||||
return &ffcli.Command{
|
|
||||||
Name: "service",
|
|
||||||
ShortHelp: "Interact with Tailscale Services",
|
|
||||||
ShortUsage: "tailscale service",
|
|
||||||
LongHelp: strings.TrimSpace(`
|
|
||||||
The 'tailscale service' command groups subcommands for Tailscale Services.
|
The 'tailscale service' command groups subcommands for Tailscale Services.
|
||||||
|
|
||||||
A Tailscale Service is a virtual service with its own IP addresses. Which
|
A Tailscale Service is a virtual service with its own IP addresses. Which
|
||||||
Services this node can reach is determined by the tailnet's ACLs. Use the 'list'
|
Services this node can reach is determined by the tailnet's ACLs. Use the 'list'
|
||||||
subcommand to see the Services currently available to this node.
|
subcommand to see the Services currently available to this node.
|
||||||
`),
|
`),
|
||||||
UsageFunc: usageFuncNoDefaultValues,
|
UsageFunc: usageFuncNoDefaultValues,
|
||||||
Exec: func(context.Context, []string) error { return flag.ErrHelp },
|
Exec: func(context.Context, []string) error { return flag.ErrHelp },
|
||||||
Subcommands: []*ffcli.Command{
|
Subcommands: []*ffcli.Command{
|
||||||
{
|
{
|
||||||
Name: "list",
|
Name: "list",
|
||||||
ShortUsage: serviceListUsage,
|
ShortUsage: serviceListUsage,
|
||||||
ShortHelp: "List the Tailscale Services your node can access",
|
ShortHelp: "List the Tailscale Services your node can access",
|
||||||
Exec: runServiceList,
|
Exec: runServiceList,
|
||||||
FlagSet: func() *flag.FlagSet {
|
FlagSet: func() *flag.FlagSet {
|
||||||
fs := newFlagSet("list")
|
fs := newFlagSet("list")
|
||||||
fs.BoolVar(&serviceListArgs.json, "json", false, "output in JSON format")
|
fs.BoolVar(&serviceListArgs.json, "json", false, "output in JSON format")
|
||||||
return fs
|
return fs
|
||||||
}(),
|
}(),
|
||||||
},
|
|
||||||
},
|
},
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
var serviceListArgs struct {
|
var serviceListArgs struct {
|
||||||
|
|||||||
@@ -355,17 +355,3 @@ func TestServiceListerFromContextDefault(t *testing.T) {
|
|||||||
t.Errorf("serviceListerFromContext default = %v, want &localClient", got)
|
t.Errorf("serviceListerFromContext default = %v, want &localClient", got)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestServiceCmdWIPGate verifies the service command is only registered when
|
|
||||||
// work-in-progress code is enabled.
|
|
||||||
func TestServiceCmdWIPGate(t *testing.T) {
|
|
||||||
t.Setenv("TAILSCALE_USE_WIP_CODE", "")
|
|
||||||
if cmd := serviceCmd(); cmd != nil {
|
|
||||||
t.Errorf("serviceCmd() = %v, want nil when WIP code is disabled", cmd)
|
|
||||||
}
|
|
||||||
|
|
||||||
t.Setenv("TAILSCALE_USE_WIP_CODE", "1")
|
|
||||||
if cmd := serviceCmd(); cmd == nil {
|
|
||||||
t.Error("serviceCmd() = nil, want non-nil when WIP code is enabled")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user