Start moving gitlab code to remote interface
This commit is contained in:
23
internal/cache/cache_load.go
vendored
23
internal/cache/cache_load.go
vendored
@@ -43,6 +43,27 @@ func (c *Cache) LoadGitlabs() {
|
||||
fmt.Println("")
|
||||
}
|
||||
|
||||
func (c *Cache) LoadRemote(client *remotes.Client, wg *sync.WaitGroup, pBar *pterm.ProgressbarPrinter, projects int) {
|
||||
defer wg.Done()
|
||||
progressInfo := client.StreamProjects(c.config.Cache.Load.OwnerOnly, projects)
|
||||
|
||||
for {
|
||||
select {
|
||||
case p := <-progressInfo.ProgressChan:
|
||||
pBar.Add(p.Projects)
|
||||
case p := <-progressInfo.ProjectsChan:
|
||||
c.AddProjects(p...)
|
||||
case e := <-progressInfo.ErrorChan:
|
||||
c.log.Error("Fetch projects error", c.log.Args("error", e, "remote", client.Config.Name))
|
||||
case <-client.Ctx.Done():
|
||||
c.log.Warn("LoadProjects cancelled", c.log.Args("reason", client.Ctx.Err()))
|
||||
return
|
||||
case <-progressInfo.DoneChan:
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Cache) LoadGitlab(client *remotes.Client, wg *sync.WaitGroup, pBar *pterm.ProgressbarPrinter, projects int) {
|
||||
defer wg.Done()
|
||||
progressInfo := client.StreamProjects(c.config.Cache.Load.OwnerOnly, projects)
|
||||
@@ -54,7 +75,7 @@ func (c *Cache) LoadGitlab(client *remotes.Client, wg *sync.WaitGroup, pBar *pte
|
||||
case p := <-progressInfo.ProjectsChan:
|
||||
c.AddProjects(p...)
|
||||
case e := <-progressInfo.ErrorChan:
|
||||
c.log.Error("Fetch GitLab projects error", c.log.Args("error", e, "gitlab", client.Config.Name))
|
||||
c.log.Error("Fetch projects error", c.log.Args("error", e, "remote", client.Config.Name))
|
||||
case <-client.Ctx.Done():
|
||||
c.log.Warn("LoadProjects cancelled", c.log.Args("reason", client.Ctx.Err()))
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user