update troubleshoot CLI (#16129)
This commit is contained in:
parent
284cf5f062
commit
1477cf5a82
|
@ -116,8 +116,9 @@ import (
|
|||
tlscacreate "github.com/hashicorp/consul/command/tls/ca/create"
|
||||
tlscert "github.com/hashicorp/consul/command/tls/cert"
|
||||
tlscertcreate "github.com/hashicorp/consul/command/tls/cert/create"
|
||||
troubleshoot "github.com/hashicorp/consul/command/troubleshoot/connect"
|
||||
upstreams "github.com/hashicorp/consul/command/troubleshoot/upstreams"
|
||||
troubleshoot "github.com/hashicorp/consul/command/troubleshoot"
|
||||
troubleshootproxy "github.com/hashicorp/consul/command/troubleshoot/proxy"
|
||||
troubleshootupstreams "github.com/hashicorp/consul/command/troubleshoot/upstreams"
|
||||
"github.com/hashicorp/consul/command/validate"
|
||||
"github.com/hashicorp/consul/command/version"
|
||||
"github.com/hashicorp/consul/command/watch"
|
||||
|
@ -242,8 +243,9 @@ func RegisteredCommands(ui cli.Ui) map[string]mcli.CommandFactory {
|
|||
entry{"tls ca create", func(ui cli.Ui) (cli.Command, error) { return tlscacreate.New(ui), nil }},
|
||||
entry{"tls cert", func(ui cli.Ui) (cli.Command, error) { return tlscert.New(), nil }},
|
||||
entry{"tls cert create", func(ui cli.Ui) (cli.Command, error) { return tlscertcreate.New(ui), nil }},
|
||||
entry{"troubleshoot connect", func(ui cli.Ui) (cli.Command, error) { return troubleshoot.New(ui), nil }},
|
||||
entry{"troubleshoot upstreams", func(ui cli.Ui) (cli.Command, error) { return upstreams.New(ui), nil }},
|
||||
entry{"troubleshoot", func(ui cli.Ui) (cli.Command, error) { return troubleshoot.New(), nil }},
|
||||
entry{"troubleshoot proxy", func(ui cli.Ui) (cli.Command, error) { return troubleshootproxy.New(ui), nil }},
|
||||
entry{"troubleshoot upstreams", func(ui cli.Ui) (cli.Command, error) { return troubleshootupstreams.New(ui), nil }},
|
||||
entry{"validate", func(ui cli.Ui) (cli.Command, error) { return validate.New(ui), nil }},
|
||||
entry{"version", func(ui cli.Ui) (cli.Command, error) { return version.New(ui), nil }},
|
||||
entry{"watch", func(ui cli.Ui) (cli.Command, error) { return watch.New(ui, MakeShutdownCh()), nil }},
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package troubleshoot
|
||||
package proxy
|
||||
|
||||
import (
|
||||
"flag"
|
||||
|
@ -7,7 +7,7 @@ import (
|
|||
"os"
|
||||
|
||||
"github.com/hashicorp/consul/command/flags"
|
||||
troubleshoot "github.com/hashicorp/consul/troubleshoot/connect"
|
||||
troubleshoot "github.com/hashicorp/consul/troubleshoot"
|
||||
"github.com/mitchellh/cli"
|
||||
)
|
||||
|
||||
|
@ -31,7 +31,7 @@ type cmd struct {
|
|||
func (c *cmd) init() {
|
||||
c.flags = flag.NewFlagSet("", flag.ContinueOnError)
|
||||
|
||||
c.flags.StringVar(&c.upstream, "upstream", os.Getenv("TROUBLESHOOT_CONNECT_UPSTREAM"), "The upstream service that receives the communication. ")
|
||||
c.flags.StringVar(&c.upstream, "upstream", os.Getenv("TROUBLESHOOT_UPSTREAM"), "The upstream service that receives the communication. ")
|
||||
|
||||
defaultAdminBind := "localhost:19000"
|
||||
if adminBind := os.Getenv("ADMIN_BIND"); adminBind != "" {
|
||||
|
@ -53,7 +53,7 @@ func (c *cmd) Run(args []string) int {
|
|||
}
|
||||
|
||||
if c.upstream == "" {
|
||||
c.UI.Error("-upstream service SNI is required")
|
||||
c.UI.Error("-upstream envoy identifier is required")
|
||||
return 1
|
||||
}
|
||||
|
||||
|
@ -94,11 +94,11 @@ func (c *cmd) Help() string {
|
|||
}
|
||||
|
||||
const (
|
||||
synopsis = "Troubleshoots service mesh issues"
|
||||
synopsis = "Troubleshoots service mesh issues from the current envoy instance"
|
||||
help = `
|
||||
Usage: consul troubleshoot proxy [options]
|
||||
Connects to local envoy proxy and troubleshoots service mesh communication issues.
|
||||
Requires an upstream service SNI.
|
||||
Requires an upstream service envoy identifier.
|
||||
Examples:
|
||||
$ consul troubleshoot proxy -upstream foo
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package troubleshoot
|
||||
package proxy
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
@ -7,7 +7,7 @@ import (
|
|||
"github.com/mitchellh/cli"
|
||||
)
|
||||
|
||||
func TestTroubleshootConnectCommand_noTabs(t *testing.T) {
|
||||
func TestTroubleshootProxyCommand_noTabs(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
if strings.ContainsRune(New(cli.NewMockUi()).Help(), '\t') {
|
|
@ -0,0 +1,44 @@
|
|||
package troubleshoot
|
||||
|
||||
import (
|
||||
"github.com/hashicorp/consul/command/flags"
|
||||
"github.com/mitchellh/cli"
|
||||
)
|
||||
|
||||
func New() *cmd {
|
||||
return &cmd{}
|
||||
}
|
||||
|
||||
type cmd struct{}
|
||||
|
||||
func (c *cmd) Run(args []string) int {
|
||||
return cli.RunResultHelp
|
||||
}
|
||||
|
||||
func (c *cmd) Synopsis() string {
|
||||
return synopsis
|
||||
}
|
||||
|
||||
func (c *cmd) Help() string {
|
||||
return flags.Usage(help, nil)
|
||||
}
|
||||
|
||||
const synopsis = `CLI tools for troubleshooting Consul service mesh`
|
||||
const help = `
|
||||
Usage: consul troubleshoot <subcommand> [options]
|
||||
|
||||
This command has subcommands for troubleshooting the service mesh.
|
||||
|
||||
Here are some simple examples, and more detailed examples are available
|
||||
in the subcommands or the documentation.
|
||||
|
||||
Troubleshoot Get Upstreams
|
||||
|
||||
$ consul troubleshoot upstreams
|
||||
|
||||
Troubleshoot Proxy
|
||||
|
||||
$ consul troubleshoot proxy -upstream [options]
|
||||
|
||||
For more examples, ask for subcommand help or view the documentation.
|
||||
`
|
|
@ -0,0 +1,13 @@
|
|||
package troubleshoot
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestTroubleshootCommand_noTabs(t *testing.T) {
|
||||
t.Parallel()
|
||||
if strings.ContainsRune(New().Help(), '\t') {
|
||||
t.Fatal("help has tabs")
|
||||
}
|
||||
}
|
|
@ -7,7 +7,7 @@ import (
|
|||
"os"
|
||||
|
||||
"github.com/hashicorp/consul/command/flags"
|
||||
troubleshoot "github.com/hashicorp/consul/troubleshoot/connect"
|
||||
troubleshoot "github.com/hashicorp/consul/troubleshoot"
|
||||
"github.com/mitchellh/cli"
|
||||
)
|
||||
|
||||
|
@ -89,13 +89,13 @@ func (c *cmd) Help() string {
|
|||
}
|
||||
|
||||
const (
|
||||
synopsis = "Troubleshoots service mesh issues"
|
||||
synopsis = "Get upstream envoy identifiers for the current envoy instance"
|
||||
help = `
|
||||
Usage: consul troubleshoot upstreams [options]
|
||||
|
||||
Connects to local Envoy and lists upstream service envoy IDs.
|
||||
Connects to local Envoy and lists upstream service envoy identifiers.
|
||||
This command is used in combination with
|
||||
'consul troubleshoot connect' to diagnose issues in Consul service mesh.
|
||||
'consul troubleshoot proxy' to diagnose issues in Consul service mesh.
|
||||
Examples:
|
||||
$ consul troubleshoot upstreams
|
||||
`
|
||||
|
|
Loading…
Reference in New Issue