forked from goodwithtech/dockle
-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.go
115 lines (105 loc) · 2.52 KB
/
main.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
package main
import (
l "log"
"os"
"time"
"github.com/Portshift/dockle/pkg"
"github.com/Portshift/dockle/pkg/log"
"github.com/urfave/cli"
)
var (
version = "dev"
)
func main() {
cli.AppHelpTemplate = `NAME:
{{.Name}}{{if .Usage}} - {{.Usage}}{{end}}
USAGE:
{{if .UsageText}}{{.UsageText}}{{else}}{{.HelpName}} {{if .VisibleFlags}}[options]{{end}} {{if .ArgsUsage}}{{.ArgsUsage}}{{else}}[arguments...]{{end}}{{end}}{{if .Version}}{{if not .HideVersion}}
VERSION:
{{.Version}}{{end}}{{end}}{{if .Description}}
DESCRIPTION:
{{.Description}}{{end}}{{if len .Authors}}
AUTHOR{{with $length := len .Authors}}{{if ne 1 $length}}S{{end}}{{end}}:
{{range $index, $author := .Authors}}{{if $index}}
{{end}}{{$author}}{{end}}{{end}}{{if .VisibleCommands}}
OPTIONS:
{{range $index, $option := .VisibleFlags}}{{if $index}}
{{end}}{{$option}}{{end}}{{end}}
`
app := cli.NewApp()
app.Name = "dockle"
app.Version = version
app.ArgsUsage = "image_name"
app.Usage = "Container Image Linter for Security, Helping build the Best-Practice Docker Image, Easy to start"
app.Flags = []cli.Flag{
cli.StringFlag{
Name: "input",
Usage: "input file path instead of image name",
},
cli.StringSliceFlag{
Name: "ignore, i",
Usage: "checkpoints to ignore. You can use .dockleignore too.",
},
cli.StringFlag{
Name: "format, f",
Value: "",
Usage: "format (json)",
},
cli.StringFlag{
Name: "output, o",
Usage: "output file name",
},
cli.IntFlag{
Name: "exit-code, c",
Usage: "exit code when alert were found",
Value: 0,
},
cli.StringFlag{
Name: "exit-level, l",
Usage: "change ABEND level when use exit-code=1",
Value: "WARN",
},
cli.BoolFlag{
Name: "debug, d",
Usage: "debug mode",
},
// Registry flag
cli.DurationFlag{
Name: "timeout, t",
Value: time.Second * 90,
Usage: "docker timeout. e.g) 5s, 5m...",
},
cli.StringFlag{
Name: "authurl",
Usage: "registry authenticate url",
},
cli.StringFlag{
Name: "username",
Usage: "registry login username",
},
cli.StringFlag{
Name: "password",
Usage: "registry login password. Using --password via CLI is insecure.",
},
cli.BoolFlag{
Name: "insecure",
Usage: "registry connect insecure",
},
cli.BoolTFlag{
Name: "nonssl",
Usage: "registry connect without ssl",
},
cli.StringFlag{
Name: "cache-dir",
Usage: "cache directory",
},
}
app.Action = pkg.RunFromCli
err := app.Run(os.Args)
if err != nil {
if log.Logger != nil {
log.Fatal(err)
}
l.Fatal(err)
}
}