forked from IceWhaleTech/CasaOS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
github.go
35 lines (30 loc) · 810 Bytes
/
github.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
package service
import (
"context"
"fmt"
"github.com/google/go-github/v36/github"
"github.com/tidwall/gjson"
)
type GithubService interface {
GetManifestJsonByRepo() (image, tcp, udp string)
}
type githubService struct {
cl *github.Client
}
func (g *githubService) GetManifestJsonByRepo() (image, tcp, udp string) {
c, _, _, e := g.cl.Repositories.GetContents(context.Background(), "a624669980", "o_test_json", "/OasisManifest.json", &github.RepositoryContentGetOptions{})
if e != nil {
fmt.Println(e)
}
str, e := c.GetContent()
if e != nil {
fmt.Println(e)
}
image = gjson.Get(str, "dockerImage").String()
tcp = gjson.Get(str, "tcp_ports").Raw
udp = gjson.Get(str, "udp_ports").Raw
return
}
func GetNewGithubService(cl *github.Client) GithubService {
return &githubService{cl: cl}
}