-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinterfaces.go
More file actions
102 lines (88 loc) · 2.87 KB
/
interfaces.go
File metadata and controls
102 lines (88 loc) · 2.87 KB
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
91
92
93
94
95
96
97
98
99
100
101
102
package cpgo
import (
"context"
"net/url"
)
// ProfileFetcher retrieves raw CPU profile data from a source endpoint.
type ProfileFetcher interface {
// FetchCPUProfile returns CPU profile bytes for one sampling request.
FetchCPUProfile(ctx context.Context, req FetchProfileRequest) ([]byte, error)
}
// FetchProfileRequest defines a CPU profile fetch operation.
type FetchProfileRequest struct {
URL *url.URL
Seconds int
Headers map[string]string
}
// ProfileValidator verifies that a fetched payload is a usable CPU profile.
type ProfileValidator interface {
// ValidateCPUProfile rejects malformed or unusable profile bytes.
ValidateCPUProfile(raw []byte) error
}
// RepositoryRef uniquely identifies a repository.
type RepositoryRef struct {
Owner string
Name string
}
// BranchWriter mutates and reads repository contents through a branch workflow.
type BranchWriter interface {
// DefaultBranch resolves the repository default branch name.
DefaultBranch(ctx context.Context, repository RepositoryRef) (string, error)
// ReadFile reads file contents from a specific branch.
ReadFile(ctx context.Context, req ReadFileRequest) (ReadFileResult, error)
// UpsertFileAndForceBranch writes a file commit and updates the head branch.
UpsertFileAndForceBranch(ctx context.Context, req UpsertFileRequest) (UpsertFileResult, error)
}
// ReadFileRequest selects a file on a specific repository branch.
type ReadFileRequest struct {
Repository RepositoryRef
Branch string
Path string
}
// ReadFileResult represents an optional file read.
type ReadFileResult struct {
Content []byte
HasFile bool
}
// UpsertFileRequest describes a force-update operation for a branch file.
type UpsertFileRequest struct {
Repository RepositoryRef
BaseBranch string
HeadBranch string
Path string
Content []byte
CommitMessage string
}
// UpsertFileResult reports the branch update outcome.
type UpsertFileResult struct {
CommitSHA string
IsBranchCreated bool
}
// PullRequestService manages pull requests for the cpgo branch.
type PullRequestService interface {
// FindOpenByHead finds the open PR that matches base/head pair.
FindOpenByHead(ctx context.Context, req FindPullRequestRequest) (*PullRequest, error)
// Create opens a new pull request for the prepared branch.
Create(ctx context.Context, req CreatePullRequestRequest) (PullRequest, error)
}
// FindPullRequestRequest targets a PR lookup by repository branches.
type FindPullRequestRequest struct {
Repository RepositoryRef
BaseBranch string
HeadBranch string
}
// PullRequest holds the subset of PR metadata used by cpgo.
type PullRequest struct {
Number int
Title string
Body string
URL string
}
// CreatePullRequestRequest contains fields for opening a PR.
type CreatePullRequestRequest struct {
Repository RepositoryRef
BaseBranch string
HeadBranch string
Title string
Body string
}