MCPcopy
hub / github.com/slimtoolkit/slim / OnCommand

Function OnCommand

pkg/app/master/command/lint/handler.go:25–119  ·  view source on GitHub ↗

OnCommand implements the 'lint' command

(
	xc *app.ExecutionContext,
	gparams *command.GenericParams,
	targetRef string,
	targetType string,
	doSkipBuildContext bool,
	buildContextDir string,
	doSkipDockerignore bool,
	includeCheckLabels map[string]string,
	excludeCheckLabels map[string]string,
	includeCheckIDs map[string]struct{},
	excludeCheckIDs map[string]struct{},
	doShowNoHits bool,
	doShowSnippet bool,
	doListChecks bool)

Source from the content-addressed store, hash-verified

23
24// OnCommand implements the 'lint' command
25func OnCommand(
26 xc *app.ExecutionContext,
27 gparams *command.GenericParams,
28 targetRef string,
29 targetType string,
30 doSkipBuildContext bool,
31 buildContextDir string,
32 doSkipDockerignore bool,
33 includeCheckLabels map[string]string,
34 excludeCheckLabels map[string]string,
35 includeCheckIDs map[string]struct{},
36 excludeCheckIDs map[string]struct{},
37 doShowNoHits bool,
38 doShowSnippet bool,
39 doListChecks bool) {
40 const cmdName = Name
41 logger := log.WithFields(log.Fields{"app": appName, "cmd": cmdName})
42
43 viChan := version.CheckAsync(gparams.CheckVersion, gparams.InContainer, gparams.IsDSImage)
44
45 cmdReport := report.NewLintCommand(gparams.ReportLocation, gparams.InContainer)
46 cmdReport.State = cmd.StateStarted
47
48 xc.Out.State("started")
49 xc.Out.Info("params",
50 ovars{
51 "target": targetRef,
52 "list.checks": doListChecks,
53 })
54
55 /*
56 do it only when targetting images
57 client, err := dockerclient.New(gparams.ClientConfig)
58 if err == dockerclient.ErrNoDockerInfo {
59 exitMsg := "missing Docker connection info"
60 if gparams.InContainer && gparams.IsDSImage {
61 exitMsg = "make sure to pass the Docker connect parameters to the 'slim' container"
62 }
63 fmt.Printf("cmd=%s info=docker.connect.error message='%s'\n", cmdName, exitMsg)
64 fmt.Printf("cmd=%s state=exited version=%s location='%s'\n", cmdName, v.Current(), fsutil.ExeDir())
65 os.Exit(ectCommon | ecNoDockerConnectInfo)
66 }
67 errutil.FailOn(err)
68 */
69 var client *dockerapi.Client
70
71 if gparams.Debug {
72 version.Print(xc, cmdName, logger, client, false, gparams.InContainer, gparams.IsDSImage)
73 }
74
75 if doListChecks {
76 checks := linter.ListChecks()
77 printLintChecks(xc, checks, appName, cmdName)
78 } else {
79 cmdReport.TargetType = linter.DockerfileTargetType
80 cmdReport.TargetReference = targetRef
81
82 options := linter.Options{

Callers 1

cli.goFile · 0.70

Calls 13

SaveMethod · 0.95
CheckAsyncFunction · 0.92
NewLintCommandFunction · 0.92
PrintFunction · 0.92
ListChecksFunction · 0.92
ExecuteFunction · 0.92
FailOnFunction · 0.92
PrintCheckVersionFunction · 0.92
printLintChecksFunction · 0.85
printLintResultsFunction · 0.85
ReportLocationMethod · 0.80
StateMethod · 0.65

Tested by

no test coverage detected