-
Notifications
You must be signed in to change notification settings - Fork 112
/
Copy pathclient.go
90 lines (76 loc) · 1.64 KB
/
client.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package auth
import (
"crypto/tls"
"errors"
peerCore "github.com/libp2p/go-libp2p/core/peer"
"github.com/taubyte/tau/core/kvdb"
)
type Client interface {
InjectStaticCertificate(domain string, data []byte) error
GetCertificate(domain string) ([]byte, error)
GetStaticCertificate(domain string) (*tls.Certificate, error)
Hooks() Hooks
Projects() Projects
Repositories() Repositories
Stats() Stats
Peers(...peerCore.ID) Client
Close()
}
type Stats interface {
Database() (kvdb.Stats, error)
}
type Hook interface {
Github() (*GithubHook, error)
Bitbucket() (*BitbucketHook, error)
}
type Hooks interface {
Get(hook_id string) (Hook, error)
New(obj map[string]interface{}) (Hook, error)
List() ([]string, error)
}
type Projects interface {
New(obj map[string]interface{}) *Project
Get(project_id string) *Project
List() ([]string, error)
}
type Project struct {
Client
Id string
Name string
Provider string
Git struct {
Config Repository
Code Repository
}
}
type Repositories interface {
Github() GithubRepositories
}
type GithubRepositories interface {
New(obj map[string]interface{}) (GithubRepository, error)
Get(id int) (GithubRepository, error)
List() ([]string, error)
}
type Repository interface {
PrivateKey() string
Id() int
}
type BitbucketHook struct {
Id string
}
type GithubHook struct {
Id string
GithubId int
Secret string
}
type GithubRepository interface {
Repository
PrivateKey() string
Project() string
}
func (h *GithubHook) Github() (*GithubHook, error) {
return h, nil
}
func (h *GithubHook) Bitbucket() (*BitbucketHook, error) {
return nil, errors.New("not a Bitbucket hook")
}