commands: move operator command to separate pkg
This commit is contained in:
parent
684362b1d0
commit
fe84af448b
|
@ -27,6 +27,7 @@ import (
|
||||||
"github.com/hashicorp/consul/command/maint"
|
"github.com/hashicorp/consul/command/maint"
|
||||||
"github.com/hashicorp/consul/command/members"
|
"github.com/hashicorp/consul/command/members"
|
||||||
"github.com/hashicorp/consul/command/monitor"
|
"github.com/hashicorp/consul/command/monitor"
|
||||||
|
"github.com/hashicorp/consul/command/oper"
|
||||||
"github.com/hashicorp/consul/command/validate"
|
"github.com/hashicorp/consul/command/validate"
|
||||||
"github.com/hashicorp/consul/version"
|
"github.com/hashicorp/consul/version"
|
||||||
"github.com/mitchellh/cli"
|
"github.com/mitchellh/cli"
|
||||||
|
@ -142,12 +143,7 @@ func init() {
|
||||||
},
|
},
|
||||||
|
|
||||||
"operator": func() (cli.Command, error) {
|
"operator": func() (cli.Command, error) {
|
||||||
return &OperatorCommand{
|
return oper.New(), nil
|
||||||
BaseCommand: BaseCommand{
|
|
||||||
Flags: FlagSetNone,
|
|
||||||
UI: ui,
|
|
||||||
},
|
|
||||||
}, nil
|
|
||||||
},
|
},
|
||||||
|
|
||||||
"operator autopilot": func() (cli.Command, error) {
|
"operator autopilot": func() (cli.Command, error) {
|
||||||
|
|
|
@ -1,20 +1,25 @@
|
||||||
package command
|
package oper
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/mitchellh/cli"
|
"github.com/mitchellh/cli"
|
||||||
)
|
)
|
||||||
|
|
||||||
// OperatorCommand is used to provide various low-level tools for Consul
|
func New() *cmd {
|
||||||
// operators.
|
return &cmd{}
|
||||||
type OperatorCommand struct {
|
|
||||||
BaseCommand
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *OperatorCommand) Help() string {
|
type cmd struct{}
|
||||||
helpText := `
|
|
||||||
Usage: consul operator <subcommand> [options]
|
func (c *cmd) Run(args []string) int {
|
||||||
|
return cli.RunResultHelp
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *cmd) Synopsis() string {
|
||||||
|
return "Provides cluster-level tools for Consul operators"
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *cmd) Help() string {
|
||||||
|
s := `Usage: consul operator <subcommand> [options]
|
||||||
|
|
||||||
Provides cluster-level tools for Consul operators, such as interacting with
|
Provides cluster-level tools for Consul operators, such as interacting with
|
||||||
the Raft subsystem. NOTE: Use this command with extreme caution, as improper
|
the Raft subsystem. NOTE: Use this command with extreme caution, as improper
|
||||||
|
@ -27,14 +32,5 @@ Usage: consul operator <subcommand> [options]
|
||||||
Run consul operator <subcommand> with no arguments for help on that
|
Run consul operator <subcommand> with no arguments for help on that
|
||||||
subcommand.
|
subcommand.
|
||||||
`
|
`
|
||||||
return strings.TrimSpace(helpText)
|
return s
|
||||||
}
|
|
||||||
|
|
||||||
func (c *OperatorCommand) Run(args []string) int {
|
|
||||||
return cli.RunResultHelp
|
|
||||||
}
|
|
||||||
|
|
||||||
// Synopsis returns a one-line description of this command.
|
|
||||||
func (c *OperatorCommand) Synopsis() string {
|
|
||||||
return "Provides cluster-level tools for Consul operators"
|
|
||||||
}
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
package oper
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strings"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestOperatorCommand_noTabs(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
if strings.ContainsRune(New().Help(), '\t') {
|
||||||
|
t.Fatal("usage has tabs")
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,12 +0,0 @@
|
||||||
package command
|
|
||||||
|
|
||||||
import (
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/mitchellh/cli"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestOperator_Implements(t *testing.T) {
|
|
||||||
t.Parallel()
|
|
||||||
var _ cli.Command = &OperatorCommand{}
|
|
||||||
}
|
|
Loading…
Reference in New Issue