githubapi

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2021 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package githubapi is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsRepoSourceGithub

func IsRepoSourceGithub(repoSourceToCompare string) bool

IsRepoSourceGithub returns true if the repo source is from github

Types

type AccessToken

type AccessToken struct {
	ExpiresAt string `json:"expires_at"`
	Token     string `json:"token"`
}

AccessToken represents a Github access token

type AnyEvent

type AnyEvent struct {
	Installation Installation `json:"installation"`
	Repository   *Repository  `json:"repository"`
}

AnyEvent represents any of the Github webhook events, to check if installation is allowed

func (*AnyEvent) GetRepository

func (ae *AnyEvent) GetRepository() string

type Author

type Author struct {
	Email    string `json:"email"`
	Name     string `json:"name"`
	UserName string `json:"username"`
}

Author represents a Github author

type Client

type Client interface {
	GetGithubAppToken(ctx context.Context) (token string, err error)
	GetInstallationID(ctx context.Context, repoOwner string) (installationID int, err error)
	GetInstallationToken(ctx context.Context, installationID int) (token AccessToken, err error)
	GetEstafetteManifest(ctx context.Context, accesstoken AccessToken, event PushEvent) (valid bool, manifest string, err error)
	JobVarsFunc(ctx context.Context) func(ctx context.Context, repoSource, repoOwner, repoName string) (token string, err error)
}

Client is the interface for communicating with the github api

func NewClient

func NewClient(config *api.APIConfig) Client

NewClient creates an githubapi.Client to communicate with the Github api

func NewLoggingClient

func NewLoggingClient(c Client) Client

NewLoggingClient returns a new instance of a logging Client.

func NewMetricsClient

func NewMetricsClient(c Client, requestCount metrics.Counter, requestLatency metrics.Histogram) Client

NewMetricsClient returns a new instance of a metrics Client.

func NewTracingClient

func NewTracingClient(c Client) Client

NewTracingClient returns a new instance of a tracing Client.

type Commit

type Commit struct {
	Author  Author `json:"author"`
	Message string `json:"message"`
	ID      string `json:"id"`
}

Commit represents a Github commit

type Installation

type Installation struct {
	ID int `json:"id"`
}

Installation represents an installation of a Github app

type MockClient

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

MockClient is a mock of Client interface.

func NewMockClient

func NewMockClient(ctrl *gomock.Controller) *MockClient

NewMockClient creates a new mock instance.

func (*MockClient) EXPECT

func (m *MockClient) EXPECT() *MockClientMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockClient) GetEstafetteManifest

func (m *MockClient) GetEstafetteManifest(ctx context.Context, accesstoken AccessToken, event PushEvent) (bool, string, error)

GetEstafetteManifest mocks base method.

func (*MockClient) GetGithubAppToken

func (m *MockClient) GetGithubAppToken(ctx context.Context) (string, error)

GetGithubAppToken mocks base method.

func (*MockClient) GetInstallationID

func (m *MockClient) GetInstallationID(ctx context.Context, repoOwner string) (int, error)

GetInstallationID mocks base method.

func (*MockClient) GetInstallationToken

func (m *MockClient) GetInstallationToken(ctx context.Context, installationID int) (AccessToken, error)

GetInstallationToken mocks base method.

func (*MockClient) JobVarsFunc

func (m *MockClient) JobVarsFunc(ctx context.Context) func(context.Context, string, string, string) (string, error)

JobVarsFunc mocks base method.

type MockClientMockRecorder

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

MockClientMockRecorder is the mock recorder for MockClient.

func (*MockClientMockRecorder) GetEstafetteManifest

func (mr *MockClientMockRecorder) GetEstafetteManifest(ctx, accesstoken, event interface{}) *gomock.Call

GetEstafetteManifest indicates an expected call of GetEstafetteManifest.

func (*MockClientMockRecorder) GetGithubAppToken

func (mr *MockClientMockRecorder) GetGithubAppToken(ctx interface{}) *gomock.Call

GetGithubAppToken indicates an expected call of GetGithubAppToken.

func (*MockClientMockRecorder) GetInstallationID

func (mr *MockClientMockRecorder) GetInstallationID(ctx, repoOwner interface{}) *gomock.Call

GetInstallationID indicates an expected call of GetInstallationID.

func (*MockClientMockRecorder) GetInstallationToken

func (mr *MockClientMockRecorder) GetInstallationToken(ctx, installationID interface{}) *gomock.Call

GetInstallationToken indicates an expected call of GetInstallationToken.

func (*MockClientMockRecorder) JobVarsFunc

func (mr *MockClientMockRecorder) JobVarsFunc(ctx interface{}) *gomock.Call

JobVarsFunc indicates an expected call of JobVarsFunc.

type PushEvent

type PushEvent struct {
	After        string       `json:"after"`
	Commits      []Commit     `json:"commits"`
	HeadCommit   Commit       `json:"head_commit"`
	Pusher       Pusher       `json:"pusher"`
	Repository   Repository   `json:"repository"`
	Installation Installation `json:"installation"`
	Ref          string       `json:"ref"`
}

PushEvent represents a Github webhook push event

func (*PushEvent) GetRepoBranch

func (pe *PushEvent) GetRepoBranch() string

GetRepoBranch returns the branch of the push event

func (*PushEvent) GetRepoFullName

func (pe *PushEvent) GetRepoFullName() string

GetRepoFullName returns the repository owner and name

func (*PushEvent) GetRepoName

func (pe *PushEvent) GetRepoName() string

GetRepoName returns the repository name

func (*PushEvent) GetRepoOwner

func (pe *PushEvent) GetRepoOwner() string

GetRepoOwner returns the repository owner

func (*PushEvent) GetRepoRevision

func (pe *PushEvent) GetRepoRevision() string

GetRepoRevision returns the revision of the push event

func (*PushEvent) GetRepoSource

func (pe *PushEvent) GetRepoSource() string

GetRepoSource returns the repository source

func (*PushEvent) GetRepository

func (pe *PushEvent) GetRepository() string

GetRepository returns the full path to the repository

type Pusher

type Pusher struct {
	Email string `json:"email"`
	Name  string `json:"name"`
}

Pusher represents a Github pusher

type Repository

type Repository struct {
	GitURL   string `json:"git_url"`
	HTMLURL  string `json:"html_url"`
	Name     string `json:"name"`
	FullName string `json:"full_name"`
}

Repository represents a Github repository

type RepositoryChanges

type RepositoryChanges struct {
	Repository RepositoryChangesRepository `json:"repository"`
}

RepositoryChanges records changes made to a repository

type RepositoryChangesRepository

type RepositoryChangesRepository struct {
	Name RepositoryChangesRepositoryName `json:"name"`
}

RepositoryChangesRepository records changes made to a repository

type RepositoryChangesRepositoryName

type RepositoryChangesRepositoryName struct {
	From string `json:"from"`
}

RepositoryChangesRepositoryName records changes made to a repository's name

type RepositoryContent

type RepositoryContent struct {
	Type     string `json:"type"`
	Encoding string `json:"encoding"`
	Size     int    `json:"size"`
	Name     string `json:"name"`
	Path     string `json:"path"`
	Content  string `json:"content"`
	Sha      string `json:"sha"`
}

RepositoryContent represents a file retrieved via the Github api

type RepositoryEvent

type RepositoryEvent struct {
	Action       string            `json:"action"`
	Changes      RepositoryChanges `json:"changes"`
	Repository   Repository        `json:"repository"`
	Installation Installation      `json:"installation"`
}

RepositoryEvent represents a Github webhook repository event

func (*RepositoryEvent) GetNewRepoName

func (pe *RepositoryEvent) GetNewRepoName() string

GetNewRepoName returns the new repository name

func (*RepositoryEvent) GetNewRepoOwner

func (pe *RepositoryEvent) GetNewRepoOwner() string

GetNewRepoOwner returns the new repository owner

func (*RepositoryEvent) GetOldRepoName

func (pe *RepositoryEvent) GetOldRepoName() string

GetOldRepoName returns the former repository name

func (*RepositoryEvent) GetOldRepoOwner

func (pe *RepositoryEvent) GetOldRepoOwner() string

GetOldRepoOwner returns the former repository owner

func (*RepositoryEvent) GetRepoName

func (pe *RepositoryEvent) GetRepoName() string

GetRepoName returns the current repository name

func (*RepositoryEvent) GetRepoOwner

func (pe *RepositoryEvent) GetRepoOwner() string

GetRepoOwner returns the current repository owner

func (*RepositoryEvent) GetRepoSource

func (pe *RepositoryEvent) GetRepoSource() string

GetRepoSource returns the repository source

func (*RepositoryEvent) IsValidRenameEvent

func (pe *RepositoryEvent) IsValidRenameEvent() bool

IsValidRenameEvent returns true if all fields for a repo rename are set

Jump to

Keyboard shortcuts

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