Merge pull request #11558 from danielpacak/fix/issue_11310/preserve_default_scanner

fix(scanner): Do not override the default scanner on init
This commit is contained in:
Steven Zou 2020-04-10 12:42:39 +08:00 committed by GitHub
commit 6986af6e74
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -73,8 +73,8 @@ func EnsureDefaultScanner(scannerURL string) (err error) {
err = errors.Errorf("getting default scanner: %v", err) err = errors.Errorf("getting default scanner: %v", err)
return return
} }
if defaultScanner != nil && defaultScanner.URL == scannerURL { if defaultScanner != nil {
log.Infof("The default scanner is already set: %s", defaultScanner.URL) log.Infof("Skipped setting %s as the default scanner. The default scanner is already set to %s", scannerURL, defaultScanner.URL)
return return
} }
scanners, err := scannerManager.List(&q.Query{ scanners, err := scannerManager.List(&q.Query{

View File

@ -95,7 +95,7 @@ func TestEnsureDefaultScanner(t *testing.T) {
scannerManager = mgr scannerManager = mgr
mgr.On("GetDefault").Return(&scanner.Registration{ mgr.On("GetDefault").Return(&scanner.Registration{
URL: "http://trivy:8080", URL: "http://clair:8080",
}, nil) }, nil)
err := EnsureDefaultScanner("http://trivy:8080") err := EnsureDefaultScanner("http://trivy:8080")