-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
flags.go
135 lines (128 loc) · 4.26 KB
/
flags.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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
package lint
import (
log "github.com/sirupsen/logrus"
"github.com/urfave/cli/v2"
"github.com/mintoolkit/mint/pkg/app/master/command"
)
// Lint command flag names
const (
FlagTargetType = "target-type"
FlagSkipBuildContext = "skip-build-context"
FlagBuildContextDir = "build-context-dir"
FlagSkipDockerignore = "skip-dockerignore"
FlagIncludeCheckLabel = "include-check-label"
FlagExcludeCheckLabel = "exclude-check-label"
FlagIncludeCheckID = "include-check-id"
FlagIncludeCheckIDFile = "include-check-id-file"
FlagExcludeCheckID = "exclude-check-id"
FlagExcludeCheckIDFile = "exclude-check-id-file"
FlagShowNoHits = "show-nohits"
FlagShowSnippet = "show-snippet"
FlagListChecks = "list-checks"
)
// Lint command flag usage info
const (
FlagLintTargetUsage = "Target Dockerfile path (or container image)"
FlagTargetTypeUsage = "Explicitly specify the command target type (values: dockerfile, image)"
FlagSkipBuildContextUsage = "Don't try to analyze build context"
FlagBuildContextDirUsage = "Explicitly specify the build context directory"
FlagSkipDockerignoreUsage = "Don't try to analyze .dockerignore"
FlagIncludeCheckLabelUsage = "Include checks with the selected label key:value"
FlagExcludeCheckLabelUsage = "Exclude checks with the selected label key:value"
FlagIncludeCheckIDUsage = "Check ID to include"
FlagIncludeCheckIDFileUsage = "File with check IDs to include"
FlagExcludeCheckIDUsage = "Check ID to exclude"
FlagExcludeCheckIDFileUsage = "File with check IDs to exclude"
FlagShowNoHitsUsage = "Show checks with no matches"
FlagShowSnippetUsage = "Show check match snippet"
FlagListChecksUsage = "List available checks"
)
var Flags = map[string]cli.Flag{
command.FlagTarget: &cli.StringFlag{
Name: command.FlagTarget,
Value: "",
Usage: FlagLintTargetUsage,
EnvVars: []string{"DSLIM_TARGET"},
},
FlagTargetType: &cli.StringFlag{
Name: FlagTargetType,
Value: "",
Usage: FlagTargetTypeUsage,
EnvVars: []string{"DSLIM_LINT_TARGET_TYPE"},
},
FlagSkipBuildContext: &cli.BoolFlag{
Name: FlagSkipBuildContext,
Usage: FlagSkipBuildContextUsage,
EnvVars: []string{"DSLIM_LINT_SKIP_BC"},
},
FlagBuildContextDir: &cli.StringFlag{
Name: FlagBuildContextDir,
Value: "",
Usage: FlagBuildContextDirUsage,
EnvVars: []string{"DSLIM_LINT_BC_DIR"},
},
FlagSkipDockerignore: &cli.BoolFlag{
Name: FlagSkipDockerignore,
Usage: FlagSkipDockerignoreUsage,
EnvVars: []string{"DSLIM_LINT_SKIP_DI"},
},
FlagIncludeCheckLabel: &cli.StringSliceFlag{
Name: FlagIncludeCheckLabel,
Value: cli.NewStringSlice(""),
Usage: FlagIncludeCheckLabelUsage,
EnvVars: []string{"DSLIM_LINT_INCLUDE_LABEL"},
},
FlagExcludeCheckLabel: &cli.StringSliceFlag{
Name: FlagExcludeCheckLabel,
Value: cli.NewStringSlice(""),
Usage: FlagExcludeCheckLabelUsage,
EnvVars: []string{"DSLIM_LINT_EXCLUDE_LABEL"},
},
FlagIncludeCheckID: &cli.StringSliceFlag{
Name: FlagIncludeCheckID,
Value: cli.NewStringSlice(""),
Usage: FlagIncludeCheckIDUsage,
EnvVars: []string{"DSLIM_LINT_INCLUDE_CID"},
},
FlagIncludeCheckIDFile: &cli.StringFlag{
Name: FlagIncludeCheckIDFile,
Value: "",
Usage: FlagIncludeCheckIDFileUsage,
EnvVars: []string{"DSLIM_LINT_INCLUDE_CID_FILE"},
},
FlagExcludeCheckID: &cli.StringSliceFlag{
Name: FlagExcludeCheckID,
Value: cli.NewStringSlice(""),
Usage: FlagExcludeCheckIDUsage,
EnvVars: []string{"DSLIM_LINT_EXCLUDE_CID"},
},
FlagExcludeCheckIDFile: &cli.StringFlag{
Name: FlagExcludeCheckIDFile,
Value: "",
Usage: FlagExcludeCheckIDFileUsage,
EnvVars: []string{"DSLIM_LINT_EXCLUDE_CID_FILE"},
},
FlagShowNoHits: &cli.BoolFlag{
Name: FlagShowNoHits,
Usage: FlagShowNoHitsUsage,
EnvVars: []string{"DSLIM_LINT_SHOW_NOHITS"},
},
FlagShowSnippet: &cli.BoolFlag{
Name: FlagShowSnippet,
Value: true,
Usage: FlagShowSnippetUsage,
EnvVars: []string{"DSLIM_LINT_SHOW_SNIPPET"},
},
FlagListChecks: &cli.BoolFlag{
Name: FlagListChecks,
Usage: FlagListChecksUsage,
EnvVars: []string{"DSLIM_LINT_LIST_CHECKS"},
},
}
func cflag(name string) cli.Flag {
cf, ok := Flags[name]
if !ok {
log.Fatalf("unknown flag='%s'", name)
}
return cf
}