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)
| 23 | |
| 24 | // OnCommand implements the 'lint' command |
| 25 | func 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{ |
no test coverage detected