You've already forked CasaOS
mirror of
https://github.com/IceWhaleTech/CasaOS.git
synced 2025-07-06 23:37:26 +02:00
first commit
This commit is contained in:
35
service/github.go
Normal file
35
service/github.go
Normal file
@ -0,0 +1,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}
|
||||
}
|
Reference in New Issue
Block a user