mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-23 10:45:45 +01:00
Merge pull request #4157 from ywk253100/180129_gas
Fix code issues found by Gas
This commit is contained in:
commit
fbef56e071
@ -100,7 +100,9 @@ func schedulePolicy(notification ScanPolicyNotification) error {
|
||||
OffsetTime: notification.DailyTime,
|
||||
})
|
||||
attachTask := task.NewScanAllTask()
|
||||
schedulePolicy.AttachTasks(attachTask)
|
||||
if err := schedulePolicy.AttachTasks(attachTask); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return scheduler.DefaultScheduler.Schedule(schedulePolicy)
|
||||
}
|
||||
|
@ -100,7 +100,9 @@ func TestTCPConn(addr string, timeout, interval int) error {
|
||||
time.Sleep(time.Duration(interval) * time.Second)
|
||||
continue
|
||||
}
|
||||
conn.Close()
|
||||
if err = conn.Close(); err != nil {
|
||||
log.Errorf("failed to close the connection: %v", err)
|
||||
}
|
||||
success <- 1
|
||||
break
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ func NewLogger(j Job) (*log.Logger, error) {
|
||||
logFile := j.LogPath()
|
||||
d := filepath.Dir(logFile)
|
||||
if _, err := os.Stat(d); os.IsNotExist(err) {
|
||||
err := os.MkdirAll(d, 0755)
|
||||
err := os.MkdirAll(d, 0700)
|
||||
if err != nil {
|
||||
log.Errorf("Failed to create directory for log file %s, the error: %v", logFile, err)
|
||||
}
|
||||
|
@ -158,9 +158,11 @@ func (l *Auth) PostAuthenticate(u *models.User) error {
|
||||
if !Re.MatchString(u.Email) {
|
||||
log.Debugf("Not a valid email address: %v, skip to sync", u.Email)
|
||||
} else {
|
||||
dao.ChangeUserProfile(*u, "Email")
|
||||
if err = dao.ChangeUserProfile(*u, "Email"); err != nil {
|
||||
u.Email = dbUser.Email
|
||||
log.Errorf("failed to sync user email: %v", err)
|
||||
}
|
||||
}
|
||||
u.Email = dbUser.Email
|
||||
}
|
||||
|
||||
return nil
|
||||
|
@ -116,7 +116,9 @@ func main() {
|
||||
scheduler.DefaultScheduler.Start()
|
||||
|
||||
//Subscribe the policy change topic.
|
||||
notifier.Subscribe(notifier.ScanAllPolicyTopic, ¬ifier.ScanPolicyNotificationHandler{})
|
||||
if err = notifier.Subscribe(notifier.ScanAllPolicyTopic, ¬ifier.ScanPolicyNotificationHandler{}); err != nil {
|
||||
log.Errorf("failed to subscribe scan all policy change topic: %v", err)
|
||||
}
|
||||
|
||||
//Get policy configuration.
|
||||
scanAllPolicy := config.ScanAllPolicy()
|
||||
@ -129,7 +131,10 @@ func main() {
|
||||
}
|
||||
|
||||
//Send notification to handle first policy change.
|
||||
notifier.Publish(notifier.ScanAllPolicyTopic, notifier.ScanPolicyNotification{Type: scanAllPolicy.Type, DailyTime: (int64)(dailyTime)})
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
if err := core.Init(); err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user