Documentation
¶
Index ¶
- Constants
- Variables
- func InterceptGetRepositoryContentResponse(res *http.Response) error
- func New(cfg *any.Any, logger *zap.Logger, scope tally.Scope) (service.Service, error)
- type Client
- type Commit
- type CreateBranchRequest
- type Directory
- type Entry
- type File
- type FileMap
- type PullRequestInfo
- type RemoteRef
- type Repository
- type StatsRoundTripper
Constants ¶
View Source
const ( Name = "clutch.service.github" CurrentUser = "" )
View Source
const ( // From https://docs.github.com/en/rest/using-the-rest-api/getting-started-with-the-rest-api?apiVersion=2022-11-28#media-types // and https://docs2.lfe.io/v3/media/ AcceptGithubRawMediaType = "application/vnd.github.v3.raw+json" // From https://cs.opensource.google/go/go/+/master:src/encoding/json/scanner.go;l=593?q=scanner.go&ss=go%2Fgo JSONSyntaxErrorPrefix = "invalid character" )
Variables ¶
View Source
var GetRepositoryContentRegex = regexp.MustCompile(`^\/repos\/[\w-]+\/[\w-]+\/contents\/[\w-.\/]+$`)
RegEx only for `Repositories.GetContents` must match something like `/repos/lyft/clutch/contents/README.md`
Functions ¶
func InterceptGetRepositoryContentResponse ¶
`Repositories.GetContents“ method cannot process a raw response, so we intercept it
Types ¶
type Client ¶
type Client interface {
GetFile(ctx context.Context, ref *RemoteRef, path string) (*File, error)
GetDirectory(ctx context.Context, ref *RemoteRef, path string) (*Directory, error)
CreateBranch(ctx context.Context, req *CreateBranchRequest) error
CreatePullRequest(ctx context.Context, ref *RemoteRef, base, title, body string) (*PullRequestInfo, error)
CreateRepository(ctx context.Context, req *sourcecontrolv1.CreateRepositoryRequest) (*sourcecontrolv1.CreateRepositoryResponse, error)
CreateIssueComment(ctx context.Context, ref *RemoteRef, number int, body string) error
CompareCommits(ctx context.Context, ref *RemoteRef, compareSHA string) (*githubv3.CommitsComparison, error)
GetCommit(ctx context.Context, ref *RemoteRef) (*Commit, error)
GetRepository(ctx context.Context, ref *RemoteRef) (*Repository, error)
GetOrganization(ctx context.Context, organization string) (*githubv3.Organization, error)
ListOrganizations(ctx context.Context, user string) ([]*githubv3.Organization, error)
ListPullRequestsWithCommit(ctx context.Context, ref *RemoteRef, sha string, opts *githubv3.ListOptions) ([]*PullRequestInfo, error)
GetOrgMembership(ctx context.Context, user, org string) (*githubv3.Membership, error)
GetUser(ctx context.Context, username string) (*githubv3.User, error)
GetPullRequest(ctx context.Context, owner, repo string, number int) (*githubv3.PullRequest, error)
DeleteFile(ctx context.Context, ref *RemoteRef, path, sha, message string) (*githubv3.RepositoryContentResponse, error)
CreateCommit(ctx context.Context, ref *RemoteRef, message string, files FileMap) (*Commit, error)
SearchCode(ctx context.Context, query string, opts *githubv3.SearchOptions) (*githubv3.CodeSearchResult, error)
GetFileContents(ctx context.Context, ref *RemoteRef, path string) (*githubv3.RepositoryContent, error)
ListCheckRunsForRef(ctx context.Context, ref *RemoteRef, opts *githubv3.ListCheckRunsOptions) (*githubv3.ListCheckRunsResults, error)
SearchIssues(ctx context.Context, query string, opts *githubv3.SearchOptions) (*githubv3.IssuesSearchResult, error)
ListReviews(ctx context.Context, ref *RemoteRef, number int, opts *githubv3.ListOptions) ([]*githubv3.PullRequestReview, error)
}
Client allows various interactions with remote repositories on GitHub.
type CreateBranchRequest ¶
type CreateBranchRequest struct {
// The base for the new branch.
Ref *RemoteRef
// The name of the new branch.
BranchName string
// Files and their content. Files will be clobbered with new content or created if they don't already exist.
Files FileMap
// The commit message for files added.
CommitMessage string
// Fetch only ReferenceName specified branch.
SingleBranch bool
}
type File ¶
type File struct {
Path string
Contents io.ReadCloser
SHA string
LastModifiedTime time.Time
LastModifiedSHA string
}
File contains information about a requested file, including its content.
type FileMap ¶
type FileMap map[string]io.ReadCloser
type PullRequestInfo ¶
type RemoteRef ¶
type RemoteRef struct {
// Organization or user that owns the repository.
RepoOwner string
// Name of the repository.
RepoName string
// SHA, branch name, or tag.
Ref string
}
Remote ref points to a git reference using a combination of the repository and the reference itself.
type Repository ¶
Repository contains information about a requested repository.
type StatsRoundTripper ¶
type StatsRoundTripper struct {
Wrapped http.RoundTripper
AcceptRaw bool
// contains filtered or unexported fields
}
Click to show internal directories.
Click to hide internal directories.