mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-26 04:05:40 +01:00
No scan all policy if Clair is not installed.
This commit fixes #5283 by not registering scan all policy when Harbor is not deployed with Clair.
This commit is contained in:
parent
9fba539bd4
commit
97fb67f835
@ -95,15 +95,6 @@ func main() {
|
||||
if err := dao.InitDatabase(database); err != nil {
|
||||
log.Fatalf("failed to initialize database: %v", err)
|
||||
}
|
||||
if config.WithClair() {
|
||||
clairDB, err := config.ClairDB()
|
||||
if err != nil {
|
||||
log.Fatalf("failed to load clair database information: %v", err)
|
||||
}
|
||||
if err := dao.InitClairDB(clairDB); err != nil {
|
||||
log.Fatalf("failed to initialize clair database: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
password, err := config.InitialAdminPassword()
|
||||
if err != nil {
|
||||
@ -126,20 +117,29 @@ func main() {
|
||||
log.Errorf("failed to subscribe scan all policy change topic: %v", err)
|
||||
}
|
||||
|
||||
//Get policy configuration.
|
||||
scanAllPolicy := config.ScanAllPolicy()
|
||||
if scanAllPolicy.Type == notifier.PolicyTypeDaily {
|
||||
dailyTime := 0
|
||||
if t, ok := scanAllPolicy.Parm["daily_time"]; ok {
|
||||
if reflect.TypeOf(t).Kind() == reflect.Int {
|
||||
dailyTime = t.(int)
|
||||
}
|
||||
if config.WithClair() {
|
||||
clairDB, err := config.ClairDB()
|
||||
if err != nil {
|
||||
log.Fatalf("failed to load clair database information: %v", err)
|
||||
}
|
||||
if err := dao.InitClairDB(clairDB); err != nil {
|
||||
log.Fatalf("failed to initialize clair database: %v", err)
|
||||
}
|
||||
//Get policy configuration.
|
||||
scanAllPolicy := config.ScanAllPolicy()
|
||||
if scanAllPolicy.Type == notifier.PolicyTypeDaily {
|
||||
dailyTime := 0
|
||||
if t, ok := scanAllPolicy.Parm["daily_time"]; ok {
|
||||
if reflect.TypeOf(t).Kind() == reflect.Int {
|
||||
dailyTime = t.(int)
|
||||
}
|
||||
}
|
||||
|
||||
//Send notification to handle first policy change.
|
||||
if err = notifier.Publish(notifier.ScanAllPolicyTopic,
|
||||
notifier.ScanPolicyNotification{Type: scanAllPolicy.Type, DailyTime: (int64)(dailyTime)}); err != nil {
|
||||
log.Errorf("failed to publish scan all policy topic: %v", err)
|
||||
//Send notification to handle first policy change.
|
||||
if err = notifier.Publish(notifier.ScanAllPolicyTopic,
|
||||
notifier.ScanPolicyNotification{Type: scanAllPolicy.Type, DailyTime: (int64)(dailyTime)}); err != nil {
|
||||
log.Errorf("failed to publish scan all policy topic: %v", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user