-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
51 lines (45 loc) · 978 Bytes
/
main.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
48
49
50
51
package main
import (
"fmt"
"log"
"time"
"github.com/eferhatg/git-batch-webhook/provider"
"github.com/joho/godotenv"
)
func main() {
err := godotenv.Load()
if err != nil {
log.Fatal("Error loading .env file")
return
}
fmt.Println("Environment arguments loaded")
btb := provider.NewBitbucket()
err = btb.Authenticate()
if err != nil {
log.Fatal(err.Error())
return
}
if btb.Token.AccessToken == "" {
log.Fatal("Couldn't be authenticated to bitbucket api")
return
}
fmt.Println("Authenticated to bitbucket api")
err = btb.CheckPermissions()
if err != nil {
log.Fatal(err.Error())
return
}
fmt.Println("Permissions checked and no problem found")
err = btb.CheckScopes()
if err != nil {
log.Fatal(err.Error())
return
}
fmt.Println("Scopes checked and no problem found")
btb.GetRepositories()
for _, repo := range btb.Repositories {
time.Sleep(1 * time.Second)
btb.AddWebHook(repo)
fmt.Println("Added:" + repo.Fullname)
}
}