-
Notifications
You must be signed in to change notification settings - Fork 0
/
gorgon.go
47 lines (38 loc) · 930 Bytes
/
gorgon.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package main
import (
"os"
"github.com/schollz/progressbar"
"github.com/theonlyjohnny/gorgon/common"
logPkg "github.com/theonlyjohnny/gorgon/log"
"github.com/theonlyjohnny/gorgon/repo"
)
var (
bar *progressbar.ProgressBar
log = logPkg.Log
testToken = os.Getenv("GITHUB_TOKEN")
)
func listenToProgressChan(progressChan <-chan common.Progress) {
for {
progress := <-progressChan
if bar == nil {
bar = progressbar.New(progress.Total)
bar.RenderBlank()
}
bar.Set(progress.Current)
}
}
func main() {
if testToken == "" {
log.Errorf("No GITHUB_TOKEN env var set -- exiting")
os.Exit(1)
}
progressChan := make(chan common.Progress, 1)
go listenToProgressChan(progressChan)
containers, err := repo.GetContainersFromGitUser(testToken, progressChan)
close(progressChan)
if err != nil {
log.Errorf("Error: %s", err.Error())
os.Exit(1)
}
log.Infof("Containers: %s", containers)
}