mirror of
https://github.com/docker/compose.git
synced 2025-07-23 05:34:36 +02:00
Merge pull request #1395 from gtardif/scan_cli_config
Don’t use context for scan suggest message, use cliconfig.Dir() as in scan plugin for consistency
This commit is contained in:
commit
482d1ea534
@ -50,7 +50,7 @@ func (s *composeService) Build(ctx context.Context, project *types.Project, opti
|
|||||||
|
|
||||||
err := s.build(ctx, project, opts, options.Progress)
|
err := s.build(ctx, project, opts, options.Progress)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
displayScanSuggestMsg(ctx, imagesToBuild)
|
displayScanSuggestMsg(imagesToBuild)
|
||||||
}
|
}
|
||||||
|
|
||||||
return err
|
return err
|
||||||
@ -100,7 +100,7 @@ func (s *composeService) ensureImagesExists(ctx context.Context, project *types.
|
|||||||
|
|
||||||
err := s.build(ctx, project, opts, "auto")
|
err := s.build(ctx, project, opts, "auto")
|
||||||
if err == nil {
|
if err == nil {
|
||||||
displayScanSuggestMsg(ctx, imagesToBuild)
|
displayScanSuggestMsg(imagesToBuild)
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
package compose
|
package compose
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
@ -26,25 +25,24 @@ import (
|
|||||||
|
|
||||||
pluginmanager "github.com/docker/cli/cli-plugins/manager"
|
pluginmanager "github.com/docker/cli/cli-plugins/manager"
|
||||||
"github.com/docker/cli/cli/command"
|
"github.com/docker/cli/cli/command"
|
||||||
"github.com/docker/compose-cli/api/config"
|
cliConfig "github.com/docker/cli/cli/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
func displayScanSuggestMsg(ctx context.Context, builtImages []string) {
|
func displayScanSuggestMsg(builtImages []string) {
|
||||||
if len(builtImages) <= 0 {
|
if len(builtImages) <= 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if os.Getenv("DOCKER_SCAN_SUGGEST") == "false" {
|
if os.Getenv("DOCKER_SCAN_SUGGEST") == "false" {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if !scanAvailable() || scanAlreadyInvoked(ctx) {
|
if !scanAvailable() || scanAlreadyInvoked() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
fmt.Println("Use 'docker scan' to run Snyk tests against images to find vulnerabilities and learn how to fix them")
|
fmt.Println("Use 'docker scan' to run Snyk tests against images to find vulnerabilities and learn how to fix them")
|
||||||
}
|
}
|
||||||
|
|
||||||
func scanAlreadyInvoked(ctx context.Context) bool {
|
func scanAlreadyInvoked() bool {
|
||||||
configDir := config.Dir(ctx)
|
filename := filepath.Join(cliConfig.Dir(), "scan", "config.json")
|
||||||
filename := filepath.Join(configDir, "scan", "config.json")
|
|
||||||
f, err := os.Stat(filename)
|
f, err := os.Stat(filename)
|
||||||
if os.IsNotExist(err) {
|
if os.IsNotExist(err) {
|
||||||
return false
|
return false
|
||||||
|
Loading…
x
Reference in New Issue
Block a user