Allow users to turn off scan suggest with env var

Signed-off-by: Guillaume Tardif <guillaume.tardif@gmail.com>
This commit is contained in:
Guillaume Tardif 2021-02-24 17:29:25 +01:00
parent 30631eea03
commit 81acdba670
1 changed files with 6 additions and 3 deletions

View File

@ -45,14 +45,17 @@ func (s *composeService) Build(ctx context.Context, project *types.Project) erro
err := s.build(ctx, project, opts)
if err == nil {
displayScanMessage(imagesToBuild)
displayScanSuggestMsg(imagesToBuild)
}
return err
}
func displayScanMessage(builtImages []string) {
func displayScanSuggestMsg(builtImages []string) {
if len(builtImages) > 0 {
if os.Getenv("DOCKER_SCAN_SUGGEST") == "false" {
return
}
commands := []string{}
for _, image := range builtImages {
commands = append(commands, fmt.Sprintf("docker scan %s", image))
@ -106,7 +109,7 @@ func (s *composeService) ensureImagesExists(ctx context.Context, project *types.
err := s.build(ctx, project, opts)
if err == nil {
displayScanMessage(imagesToBuild)
displayScanSuggestMsg(imagesToBuild)
}
return err
}