Skip to content

Commit

Permalink
[Ingest Manager] Align introspect-inspect naming in code (#20952) (#2…
Browse files Browse the repository at this point in the history
  • Loading branch information
michalpristas authored Sep 7, 2020
1 parent 39994b0 commit 7b7127d
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 33 deletions.
6 changes: 3 additions & 3 deletions x-pack/elastic-agent/docs/elastic-agent-command-line.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,11 @@ accepts additional flags:
+
--
`--output <string>`::
The name of the output to introspect.
The name of the output to inspect.

`--program <string>`::
The type of program to introspect. For example, `filebeat`. This option must be
combined with `--output`.
The type of program to inspect. For example, `filebeat`. This option must be
combined with `--output`.
--

`--help`::
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,25 @@ import (
"github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/fleetapi"
)

// IntrospectConfigCmd is an introspect subcommand that shows configurations of the agent.
type IntrospectConfigCmd struct {
// InspectConfigCmd is an inspect subcommand that shows configurations of the agent.
type InspectConfigCmd struct {
cfgPath string
}

// NewIntrospectConfigCmd creates a new introspect command.
func NewIntrospectConfigCmd(configPath string,
) (*IntrospectConfigCmd, error) {
return &IntrospectConfigCmd{
// NewInspectConfigCmd creates a new inspect command.
func NewInspectConfigCmd(configPath string,
) (*InspectConfigCmd, error) {
return &InspectConfigCmd{
cfgPath: configPath,
}, nil
}

// Execute introspects agent configuration.
func (c *IntrospectConfigCmd) Execute() error {
return c.introspectConfig()
// Execute inspects agent configuration.
func (c *InspectConfigCmd) Execute() error {
return c.inspectConfig()
}

func (c *IntrospectConfigCmd) introspectConfig() error {
func (c *InspectConfigCmd) inspectConfig() error {
rawConfig, err := loadConfig(c.cfgPath)
if err != nil {
return err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,32 @@ import (
"github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/monitoring/noop"
)

// IntrospectOutputCmd is an introspect subcommand that shows configurations of the agent.
type IntrospectOutputCmd struct {
// InspectOutputCmd is an inspect subcommand that shows configurations of the agent.
type InspectOutputCmd struct {
cfgPath string
output string
program string
}

// NewIntrospectOutputCmd creates a new introspect command.
func NewIntrospectOutputCmd(configPath, output, program string) (*IntrospectOutputCmd, error) {
return &IntrospectOutputCmd{
// NewInspectOutputCmd creates a new inspect command.
func NewInspectOutputCmd(configPath, output, program string) (*InspectOutputCmd, error) {
return &InspectOutputCmd{
cfgPath: configPath,
output: output,
program: program,
}, nil
}

// Execute tries to enroll the agent into Fleet.
func (c *IntrospectOutputCmd) Execute() error {
func (c *InspectOutputCmd) Execute() error {
if c.output == "" {
return c.introspectOutputs()
return c.inspectOutputs()
}

return c.introspectOutput()
return c.inspectOutput()
}

func (c *IntrospectOutputCmd) introspectOutputs() error {
func (c *InspectOutputCmd) inspectOutputs() error {
rawConfig, err := loadConfig(c.cfgPath)
if err != nil {
return err
Expand Down Expand Up @@ -94,7 +94,7 @@ func listOutputsFromMap(log *logger.Logger, cfg map[string]interface{}) error {
return listOutputsFromConfig(log, c)
}

func (c *IntrospectOutputCmd) introspectOutput() error {
func (c *InspectOutputCmd) inspectOutput() error {
rawConfig, err := loadConfig(c.cfgPath)
if err != nil {
return err
Expand Down Expand Up @@ -149,15 +149,15 @@ func printOutputFromConfig(log *logger.Logger, output, programName string, cfg *
}

if !programFound {
return fmt.Errorf("program '%s' is not recognized within output '%s', try running `elastic-agent introspect output` to find available outputs",
return fmt.Errorf("program '%s' is not recognized within output '%s', try running `elastic-agent inspect output` to find available outputs",
programName,
output)
}

return nil
}

return fmt.Errorf("output '%s' is not recognized, try running `elastic-agent introspect output` to find available outputs", output)
return fmt.Errorf("output '%s' is not recognized, try running `elastic-agent inspect output` to find available outputs", output)

}

Expand Down
2 changes: 1 addition & 1 deletion x-pack/elastic-agent/pkg/agent/cmd/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func NewCommandWithArgs(args []string, streams *cli.IOStreams) *cobra.Command {
cmd.AddCommand(basecmd.NewDefaultCommandsWithArgs(args, streams)...)
cmd.AddCommand(run)
cmd.AddCommand(newEnrollCommandWithArgs(flags, args, streams))
cmd.AddCommand(newIntrospectCommandWithArgs(flags, args, streams))
cmd.AddCommand(newInspectCommandWithArgs(flags, args, streams))

// windows special hidden sub-command (only added on windows)
reexec := newReExecWindowsCommand(flags, args, streams)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ import (
"github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/cli"
)

func newIntrospectCommandWithArgs(flags *globalFlags, s []string, streams *cli.IOStreams) *cobra.Command {
func newInspectCommandWithArgs(flags *globalFlags, s []string, streams *cli.IOStreams) *cobra.Command {
cmd := &cobra.Command{
Use: "inspect",
Short: "Shows configuration of the agent",
Long: "Shows current configuration of the agent",
Args: cobra.ExactArgs(0),
Run: func(c *cobra.Command, args []string) {
command, err := application.NewIntrospectConfigCmd(flags.Config())
command, err := application.NewInspectConfigCmd(flags.Config())
if err != nil {
fmt.Fprintf(streams.Err, "%v\n", err)
os.Exit(1)
Expand All @@ -34,12 +34,12 @@ func newIntrospectCommandWithArgs(flags *globalFlags, s []string, streams *cli.I
},
}

cmd.AddCommand(newIntrospectOutputCommandWithArgs(flags, s, streams))
cmd.AddCommand(newInspectOutputCommandWithArgs(flags, s, streams))

return cmd
}

func newIntrospectOutputCommandWithArgs(flags *globalFlags, _ []string, streams *cli.IOStreams) *cobra.Command {
func newInspectOutputCommandWithArgs(flags *globalFlags, _ []string, streams *cli.IOStreams) *cobra.Command {
cmd := &cobra.Command{
Use: "output",
Short: "Displays configuration generated for output",
Expand All @@ -49,7 +49,7 @@ func newIntrospectOutputCommandWithArgs(flags *globalFlags, _ []string, streams
outName, _ := c.Flags().GetString("output")
program, _ := c.Flags().GetString("program")

command, err := application.NewIntrospectOutputCmd(flags.Config(), outName, program)
command, err := application.NewInspectOutputCmd(flags.Config(), outName, program)
if err != nil {
fmt.Fprintf(streams.Err, "%v\n", err)
os.Exit(1)
Expand All @@ -62,8 +62,8 @@ func newIntrospectOutputCommandWithArgs(flags *globalFlags, _ []string, streams
},
}

cmd.Flags().StringP("output", "o", "", "name of the output to be introspected")
cmd.Flags().StringP("program", "p", "", "type of program to introspect, needs to be combined with output. e.g filebeat")
cmd.Flags().StringP("output", "o", "", "name of the output to be inspected")
cmd.Flags().StringP("program", "p", "", "type of program to inspect, needs to be combined with output. e.g filebeat")

return cmd
}

0 comments on commit 7b7127d

Please sign in to comment.