Skip to content

Commit

Permalink
chore(cli): Rename get subcommands to be consistent with scan subcomm…
Browse files Browse the repository at this point in the history
…ands (#726)

Signed-off-by: Daniel Pacak <pacak.daniel@gmail.com>
  • Loading branch information
danielpacak authored Oct 2, 2021
1 parent c71e1d4 commit f09d170
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 27 deletions.
4 changes: 2 additions & 2 deletions pkg/cmd/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ func NewGetCmd(buildInfo starboard.BuildInfo, cf *genericclioptions.ConfigFlags,
Use: "get",
Short: "Get security reports",
}
getCmd.AddCommand(NewGetVulnerabilitiesCmd(buildInfo.Executable, cf, outWriter))
getCmd.AddCommand(NewGetConfigAuditCmd(buildInfo.Executable, cf, outWriter))
getCmd.AddCommand(NewGetVulnerabilityReportsCmd(buildInfo.Executable, cf, outWriter))
getCmd.AddCommand(NewGetConfigAuditReportsCmd(buildInfo.Executable, cf, outWriter))
getCmd.AddCommand(NewGetReportCmd(buildInfo, cf, outWriter))
getCmd.PersistentFlags().StringP("output", "o", "yaml", "Output format. One of yaml|json")

Expand Down
27 changes: 14 additions & 13 deletions pkg/cmd/get_configaudit.go → pkg/cmd/get_configauditreports.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,26 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
)

func NewGetConfigAuditCmd(executable string, cf *genericclioptions.ConfigFlags, outWriter io.Writer) *cobra.Command {
func NewGetConfigAuditReportsCmd(executable string, cf *genericclioptions.ConfigFlags, out io.Writer) *cobra.Command {
cmd := &cobra.Command{
Use: "configaudit (NAME | TYPE/NAME)",
Short: "Get configuration audit report",
Long: `Get configuration audit report for the specified workload
Use: "configauditreports (NAME | TYPE/NAME)",
Aliases: []string{"configaudit"},
Short: "Get configuration audit reports",
Long: `Get configuration audit reports for the specified resource
TYPE is a Kubernetes workload. Shortcuts and API groups will be resolved, e.g. 'po' or 'deployments.apps'.
NAME is the name of a particular Kubernetes workload.
TYPE is a Kubernetes resource. Shortcuts and API groups will be resolved, e.g. 'po' or 'deployments.apps'.
NAME is the name of a particular Kubernetes resource.
`,
Example: fmt.Sprintf(` # Get configuration audit for a Deployment with the specified name
%[1]s get configauditreports.aquasecurity.github.io deploy/nginx
Example: fmt.Sprintf(` # Get configuration audit report for a Deployment with the specified name
%[1]s get configauditreports deploy/nginx
# Get configuration audit for a Deployment with the specified name in the specified namespace
# Get configuration audit report for a Deployment with the specified name in the specified namespace
%[1]s get configauditreports deploy/nginx -n staging
# Get configuration audit for a ReplicaSet with the specified name
# Get configuration audit report for a ReplicaSet with the specified name
%[1]s get configaudit replicaset/nginx
# Get vulnerabilities for a CronJob with the specified name in JSON output format
# Get configuration audit report for a CronJob with the specified name in JSON output format
%[1]s get configaudit cj/my-job -o json`, executable),
RunE: func(cmd *cobra.Command, args []string) error {
ctx := context.Background()
Expand Down Expand Up @@ -63,7 +64,7 @@ NAME is the name of a particular Kubernetes workload.
}

if report == nil {
fmt.Fprintf(outWriter, "No reports found in %s namespace.\n", workload.Namespace)
fmt.Fprintf(out, "No reports found in %s namespace.\n", workload.Namespace)
return nil
}

Expand All @@ -76,7 +77,7 @@ NAME is the name of a particular Kubernetes workload.
return fmt.Errorf("create printer: %v", err)
}

if err := printer.PrintObj(report, outWriter); err != nil {
if err := printer.PrintObj(report, out); err != nil {
return fmt.Errorf("print vulnerability reports: %v", err)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,26 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
)

func NewGetVulnerabilitiesCmd(executable string, cf *genericclioptions.ConfigFlags, outWriter io.Writer) *cobra.Command {
func NewGetVulnerabilityReportsCmd(executable string, cf *genericclioptions.ConfigFlags, out io.Writer) *cobra.Command {
cmd := &cobra.Command{
Aliases: []string{"vulns", "vuln"},
Use: "vulnerabilities (NAME | TYPE/NAME)",
Short: "Get vulnerabilities report",
Long: `Get vulnerabilities report for the specified workload
Use: "vulnerabilityreports (NAME | TYPE/NAME)",
Aliases: []string{"vulns", "vuln", "vulnerabilities"},
Short: "Get vulnerability reports",
Long: `Get vulnerability reports for the specified workload
TYPE is a Kubernetes workload. Shortcuts and API groups will be resolved, e.g. 'po' or 'deployments.apps'.
NAME is the name of a particular Kubernetes workload.
`,
Example: fmt.Sprintf(` # Get vulnerabilities for a Deployment with the specified name
%[1]s get vulnerabilities.aquasecurity.github.io deploy/nginx
Example: fmt.Sprintf(` # Get vulnerability reports for a Deployment with the specified name
%[1]s get vulnerabilityreports deploy/nginx
# Get vulnerabilities for a Deployment with the specified name in the specified namespace
# Get vulnerability reports for a Deployment with the specified name in the specified namespace
%[1]s get vulnerabilities deploy/nginx -n staging
# Get vulnerabilities for a ReplicaSet with the specified name
# Get vulnerability reports for a ReplicaSet with the specified name
%[1]s get vulns replicaset/nginx
# Get vulnerabilities for a CronJob with the specified name in JSON output format
# Get vulnerability reports for a CronJob with the specified name in JSON output format
%[1]s get vuln cj/my-job -o json`, executable),
RunE: func(cmd *cobra.Command, args []string) error {
ctx := context.Background()
Expand Down Expand Up @@ -65,7 +65,7 @@ NAME is the name of a particular Kubernetes workload.
return fmt.Errorf("list vulnerability reports: %v", err)
}
if len(items) == 0 {
fmt.Fprintf(outWriter, "No reports found in %s namespace.\n", workload.Namespace)
fmt.Fprintf(out, "No reports found in %s namespace.\n", workload.Namespace)
return nil
}

Expand All @@ -78,7 +78,7 @@ NAME is the name of a particular Kubernetes workload.
return fmt.Errorf("create printer: %v", err)
}

if err := printer.PrintObj(&v1alpha1.VulnerabilityReportList{Items: items}, outWriter); err != nil {
if err := printer.PrintObj(&v1alpha1.VulnerabilityReportList{Items: items}, out); err != nil {
return fmt.Errorf("print vulnerability reports: %v", err)
}

Expand Down

0 comments on commit f09d170

Please sign in to comment.