/
image.go
53 lines (45 loc) · 1.49 KB
/
image.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Package image manages the image analysis subcommands.
package image
import (
"github.com/spf13/cobra"
"github.com/vmware/carbon-black-cloud-container-cli/pkg/presenter"
"github.com/vmware/carbon-black-cloud-container-cli/pkg/scan"
)
type (
scanOption = scan.Option
presenterOption = presenter.Option
)
var opts struct {
scanOption
presenterOption
}
const (
fullTable = 0
defaultTimeout = 600
)
// Cmd return the command related to image analysis.
func Cmd() *cobra.Command {
cmd := &cobra.Command{
Use: "image",
Short: "Commands related to image analysis",
Long: `Commands related to image analysis`,
}
cmd.AddCommand(ScanCmd())
cmd.AddCommand(ValidateCmd())
cmd.AddCommand(PackagesCmd())
cmd.AddCommand(PayloadCmd())
cmd.PersistentFlags().StringVarP(
&opts.OutputFormat, "output", "o", "table", "output format of the result")
cmd.PersistentFlags().BoolVar(
&opts.ShouldCleanup, "cleanup", false, "clean up image (for docker only) after scanning")
cmd.PersistentFlags().BoolVar(
&opts.BypassDockerDaemon, "bypass-docker-daemon", false,
"try to pull image without docker daemon")
cmd.PersistentFlags().BoolVar(
&opts.UseDockerDaemon, "use-docker", false, "deprecated - docker daemon is now the default")
cmd.PersistentFlags().StringVar(
&opts.Credential, "cred", "", "use `USERNAME[:PASSWORD]` for accessing the registry")
cmd.PersistentFlags().IntVar(
&opts.Timeout, "timeout", defaultTimeout, "set the duration (second) for the scan process")
return cmd
}