/
types.go
45 lines (40 loc) · 1.57 KB
/
types.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
package git_provider
import (
"context"
"net/http"
)
type HookWithStatus struct {
HookID int64
Uuid string
HealthStatus bool
RepoName *string
}
type CommitFile struct {
Path *string `json:"path"`
Content *string `json:"content"`
}
type WebhookPayload struct {
Event string `json:"event"`
Action string `json:"action"`
Repo string `json:"repoName"`
Branch string `json:"branch"`
Commit string `json:"commit"`
User string `json:"user"`
UserEmail string `json:"user_email"`
PullRequestURL string `json:"pull_request_url"`
PullRequestTitle string `json:"pull_request_title"`
DestBranch string `json:"dest_branch"`
Labels []string `json:"labels"`
HookID int64 `json:"hookID"`
OwnerID int64 `json:"ownerID"`
}
type Client interface {
ListFiles(ctx *context.Context, repo string, branch string, path string) ([]string, error)
GetFile(ctx *context.Context, repo string, branch string, path string) (*CommitFile, error)
GetFiles(ctx *context.Context, repo string, branch string, paths []string) ([]*CommitFile, error)
SetWebhook(ctx *context.Context, repo *string) (*HookWithStatus, error)
UnsetWebhook(ctx *context.Context, hook *HookWithStatus) error
HandlePayload(ctx *context.Context, request *http.Request, secret []byte) (*WebhookPayload, error)
SetStatus(ctx *context.Context, repo *string, commit *string, linkURL *string, status *string, message *string) error
PingHook(ctx *context.Context, hook *HookWithStatus) error
}