github

package
v1.0.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 11, 2026 License: BSD-2-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithGithubAppAuth added in v1.0.8

func WithGithubAppAuth(ctx context.Context, signer JWTSigner, appID int64, keyAlias string) context.Context

func WithGithubToken added in v1.0.8

func WithGithubToken(ctx context.Context, token string) context.Context

Types

type API

type API interface {
	FindIssueCommentWithMarker(ctx context.Context, owner, repo string, issueNumber int, marker string) (*IssueComment, error)
	CreateIssueComment(ctx context.Context, owner, repo string, issueNumber int, body string) (*IssueComment, error)
	UpdateIssueComment(ctx context.Context, owner, repo string, commentID int64, body string) (*IssueComment, error)
	GetPullRequest(ctx context.Context, owner, repo string, number int) (*PullRequest, error)
	GetInstallationToken(ctx context.Context, installationID int64) (string, error)
}

API is the handler-facing interface satisfied by *Client. It exists for dependency injection in handler tests; the shared library provides one implementation. Methods take only the operation's intrinsic arguments; auth is applied by the authTransport on the underlying http client.

type AuthProvider added in v1.0.8

type AuthProvider interface {
	AddAuth(req *http.Request) (*http.Request, error)
}

func GetAuthProvider added in v1.0.8

func GetAuthProvider(ctx context.Context) AuthProvider

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is the GitHub API client used by handlers. It is built on top of go-github, authenticated with a static token via authTransport.

func NewClient

func NewClient(httpClient *http.Client, baseURL string) (*Client, error)

NewClient returns a Client authenticated with the supplied token, issuing requests against baseURL using httpClient's transport.

A nil httpClient falls back to http.DefaultClient. The caller's *http.Client is not mutated; we shallow-copy before installing the auth transport wrapper.

baseURL "" or "https://api.github.com" targets public GitHub. Any other value retargets the underlying go-github client at a GHES instance via WithEnterpriseURLs.

func (*Client) CreateIssueComment

func (c *Client) CreateIssueComment(ctx context.Context, owner, repo string, issueNumber int, body string) (*IssueComment, error)

CreateIssueComment creates a comment on the specified issue or pull request.

func (*Client) FindIssueCommentWithMarker

func (c *Client) FindIssueCommentWithMarker(ctx context.Context, owner, repo string, issueNumber int, marker string) (*IssueComment, error)

FindIssueCommentWithMarker lists issue comments and returns the first one whose body contains the marker string. Returns nil, nil if no matching comment is found.

func (*Client) GetInstallationToken added in v1.0.8

func (c *Client) GetInstallationToken(ctx context.Context, installationID int64) (string, error)

func (*Client) GetPullRequest

func (c *Client) GetPullRequest(ctx context.Context, owner, repo string, number int) (*PullRequest, error)

GetPullRequest retrieves a pull request by number.

func (*Client) RoundTrip added in v1.0.7

func (c *Client) RoundTrip(req *http.Request) (*http.Response, error)

func (*Client) UpdateIssueComment

func (c *Client) UpdateIssueComment(ctx context.Context, owner, repo string, commentID int64, body string) (*IssueComment, error)

UpdateIssueComment updates an existing issue comment by ID.

type IssueComment

type IssueComment struct {
	ID   int64
	Body string
}

IssueComment represents a GitHub issue or PR comment.

type JWTSigner added in v1.0.8

type JWTSigner interface {
	SignGithubJWT(ctx context.Context, token *jwt.Token, keyAlias string) error
}

JWTSigner signs a GitHub App JWT using a KMS-backed key.

type PullRequest

type PullRequest struct {
	ID    int64
	State string
	User  PullRequestUser
}

PullRequest represents a GitHub pull request as returned by GetPullRequest.

type PullRequestUser

type PullRequestUser struct {
	Login string
}

PullRequestUser carries the login of a pull request author.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL