github

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2025 License: MIT Imports: 24 Imported by: 0

Documentation

Overview

Package github provides GitHub App authentication via oauth2.TokenSource. It always returns installation tokens using a mandatory installation ID.

Package github provides utilities for manipulating GitHub branches and PRs.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoGitHubAppID is returned when no GitHub App ID is provided.
	ErrNoGitHubAppID = errors.New("no GitHub App ID provided")
	// ErrNoGitHubPrivateKey is returned when no GitHub private key is provided.
	ErrNoGitHubPrivateKey = errors.New("no GitHub private key provided")
	// ErrNoGitHubInstallationID is returned when no GitHub installation ID is provided.
	ErrNoGitHubInstallationID = errors.New("no GitHub installation ID provided")
	// ErrInvalidGitHubAppID is returned when the GitHub App ID is invalid.
	ErrInvalidGitHubAppID = errors.New("invalid GitHub App ID")
	// ErrInvalidGitHubInstallationID is returned when the GitHub installation ID is invalid.
	ErrInvalidGitHubInstallationID = errors.New("invalid GitHub installation ID")
)

Functions

func ParseRepoURL

func ParseRepoURL(repoURL string) (owner, repo string, err error)

ParseRepoURL parses a GitHub repository URL and returns owner and repo name

Types

type Client

type Client struct {
	// Rest is the GitHub REST API client.
	Rest *github.Client
	// GraphQL is the GitHub GraphQL API client.
	GraphQL *gh_graphql.Client
	// BaseURL is the base URL of the GitHub API. Defaults to the public GitHub API.
	BaseURL *url.URL
	// contains filtered or unexported fields
}

Client is a wrapper around the GitHub REST and GraphQL API clients

func NewClient

func NewClient(
	options ...ClientOption,
) (*Client, error)

NewClient creates a new GitHub REST and GraphQL API client with the provided token and logger. If optionalNext is provided, it will be used as the base client for both REST and GraphQL, handy for testing.

func (*Client) QuarantineTests

func (c *Client) QuarantineTests(
	ctx context.Context,
	l zerolog.Logger,
	owner, repo string,
	targets []golang.QuarantineTarget,
	options ...QuarantineOption,
) error

QuarantineTests quarantines multiple Go tests by adding t.Skip() to the test functions and making a PR to the default branch.

type ClientOption

type ClientOption func(*clientOptions)

ClientOption is a function that can be used to configure the GitHub client.

func WithConfig

func WithConfig(config config.Config) ClientOption

WithConfig uses a GitHub config to setup authentication.

func WithLogger

func WithLogger(logger zerolog.Logger) ClientOption

WithLogger sets the logger for the GitHub client.

type IClient

type IClient interface {
	QuarantineTests(
		ctx context.Context,
		l zerolog.Logger,
		owner, repo string,
		targets []golang.QuarantineTarget,
		options ...QuarantineOption,
	) error
}

IClient is the interface for the GitHub client.

type QuarantineOption

type QuarantineOption func(*quarantineTestsOptions)

QuarantineOption is a function that can be used to configure the QuarantineTests function.

func WithBuildFlags

func WithBuildFlags(buildFlags []string) QuarantineOption

WithBuildFlags sets the build flags to use when loading packages.

Jump to

Keyboard shortcuts

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