github

package
v0.0.47 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2023 License: MPL-2.0 Imports: 26 Imported by: 0

Documentation

Overview

Package github provides github related code

Index

Constants

View Source
const (
	DefaultGithubHostname string = "github.com"
)

Variables

This section is empty.

Functions

func Defaults

func Defaults() cloud.Config

func HandleEvent

HandleEvent handles incoming events from github

func NewEnterpriseClient

func NewEnterpriseClient(hostname string, httpClient *http.Client) (*github.Client, error)

func OAuthDefaults

func OAuthDefaults() *oauth2.Config

Types

type Client

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

func NewClient

func NewClient(ctx context.Context, cfg cloud.ClientOptions) (*Client, error)

func (*Client) CreateWebhook

func (g *Client) CreateWebhook(ctx context.Context, opts cloud.CreateWebhookOptions) (string, error)

CreateWebhook creates a webhook on a github repository.

func (*Client) DeleteWebhook

func (g *Client) DeleteWebhook(ctx context.Context, opts cloud.DeleteWebhookOptions) error

func (*Client) GetRepoTarball

func (g *Client) GetRepoTarball(ctx context.Context, opts cloud.GetRepoTarballOptions) ([]byte, error)

func (*Client) GetRepository

func (g *Client) GetRepository(ctx context.Context, identifier string) (string, error)

func (*Client) GetUser

func (g *Client) GetUser(ctx context.Context) (*cloud.User, error)

GetUser retrieves a user from github along with their team memberships. They are determined to be in the owners team if either: (a) they are a member of a github team called 'owners' (b) they are an admin of a github organization.

func (*Client) GetWebhook

func (g *Client) GetWebhook(ctx context.Context, opts cloud.GetWebhookOptions) (cloud.Webhook, error)

func (*Client) ListRepositories

func (g *Client) ListRepositories(ctx context.Context, opts cloud.ListRepositoriesOptions) ([]string, error)

func (*Client) ListTags

func (g *Client) ListTags(ctx context.Context, opts cloud.ListTagsOptions) ([]string, error)

func (*Client) SetStatus

func (g *Client) SetStatus(ctx context.Context, opts cloud.SetStatusOptions) error

func (*Client) UpdateWebhook

func (g *Client) UpdateWebhook(ctx context.Context, id string, opts cloud.UpdateWebhookOptions) error

type Cloud

type Cloud struct{}

func (Cloud) HandleEvent

func (*Cloud) NewClient

func (g *Cloud) NewClient(ctx context.Context, opts cloud.ClientOptions) (cloud.Client, error)

type GithubEvent

type GithubEvent string

The name of the event sent in the X-Github-Event header

const (
	PushEvent   GithubEvent = "push"
	PullRequest GithubEvent = "pull_request"
)

type TestServer

type TestServer struct {
	HookEndpoint *string  // populated upon creation
	HookSecret   *string  // populated upon creation
	HookEvents   []string // populated upon creation

	*httptest.Server
	// contains filtered or unexported fields
}

func NewTestServer

func NewTestServer(t *testing.T, opts ...TestServerOption) (*TestServer, cloud.Config)

func (*TestServer) GetStatus

func (s *TestServer) GetStatus(t *testing.T, ctx context.Context) *github.StatusEvent

GetStatus retrieves a commit status event off the queue, timing out after 10 seconds if nothing is on the queue.

func (*TestServer) HasWebhook

func (s *TestServer) HasWebhook() bool

func (*TestServer) SendEvent

func (s *TestServer) SendEvent(t *testing.T, event GithubEvent, payload []byte)

SendEvent sends an event to the registered webhook.

type TestServerOption

type TestServerOption func(*TestServer)

func WithArchive

func WithArchive(tarball []byte) TestServerOption

func WithRefs

func WithRefs(refs ...string) TestServerOption

func WithRepo

func WithRepo(repo string) TestServerOption

func WithUser

func WithUser(user *cloud.User) TestServerOption

Jump to

Keyboard shortcuts

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