github

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewClient

func NewClient(
	ctx context.Context,
	appID int64,
	installationID int64,
	keyPEM []byte,
) (*github.Client, error)

NewClient returns a new GitHub API client. This function abstracts the onerous process of authenticating as an installation. It uses the provided appID and ASCII-armored x509 certificate key to create a JWT (JSON web token) that is used to authenticate to the GitHub Apps API. Using that API, an installation token is obtained for the given installationID. This token is ultimately used by the returned client to authenticate as the specified installation.

See the following for further details: https://docs.github.com/en/developers/apps/authenticating-with-github-apps

Types

type App added in v0.3.0

type App struct {
	// AppID specifies the ID of the GitHub App.
	AppID int64 `json:"appID"`
	// SharedSecret is the secret mutually agreed upon by this gateway and the
	// GitHub App. This secret can be used to validate the authenticity and
	// integrity of payloads received by this gateway.
	SharedSecret string `json:"sharedSecret"`
	// APIKey is the private API key for the GitHub App.
	APIKey string `json:"apiKey"`
}

App encapsulates the details of a GitHub App that sends webbooks to this gateway.

type CheckRunsClient

type CheckRunsClient interface {
	CreateCheckRun(
		ctx context.Context,
		owner string,
		repo string,
		opts github.CreateCheckRunOptions,
	) (*github.CheckRun, *github.Response, error)
	UpdateCheckRun(
		ctx context.Context,
		owner string,
		repo string,
		checkRunID int64,
		opts github.UpdateCheckRunOptions,
	) (*github.CheckRun, *github.Response, error)
}

type CheckRunsClientFactory

type CheckRunsClientFactory interface {
	NewCheckRunsClient(
		ctx context.Context,
		appID int64,
		installationID int64,
		apiKey []byte,
	) (CheckRunsClient, error)
}

func NewCheckRunsClientFactory

func NewCheckRunsClientFactory() CheckRunsClientFactory

type MockCheckRunsClient

type MockCheckRunsClient struct {
	CreateCheckRunFn func(
		ctx context.Context,
		owner string,
		repo string,
		opts github.CreateCheckRunOptions,
	) (*github.CheckRun, *github.Response, error)
	UpdateCheckRunFn func(
		ctx context.Context,
		owner string,
		repo string,
		checkRunID int64,
		opts github.UpdateCheckRunOptions,
	) (*github.CheckRun, *github.Response, error)
}

func (*MockCheckRunsClient) CreateCheckRun

func (m *MockCheckRunsClient) CreateCheckRun(
	ctx context.Context,
	owner string,
	repo string,
	opts github.CreateCheckRunOptions,
) (*github.CheckRun, *github.Response, error)

func (*MockCheckRunsClient) UpdateCheckRun

func (m *MockCheckRunsClient) UpdateCheckRun(
	ctx context.Context,
	owner string,
	repo string,
	checkRunID int64,
	opts github.UpdateCheckRunOptions,
) (*github.CheckRun, *github.Response, error)

type MockCheckRunsClientFactory

type MockCheckRunsClientFactory struct {
	NewCheckRunsClientFn func(
		ctx context.Context,
		appID int64,
		installationID int64,
		apiKey []byte,
	) (CheckRunsClient, error)
}

func (*MockCheckRunsClientFactory) NewCheckRunsClient

func (m *MockCheckRunsClientFactory) NewCheckRunsClient(
	ctx context.Context,
	appID int64,
	installationID int64,
	apiKey []byte,
) (CheckRunsClient, error)

Jump to

Keyboard shortcuts

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