githubapi

package
v1.0.2003 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2021 License: MIT Imports: 26 Imported by: 0

Documentation

Overview

Package githubapi is a generated GoMock package.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMissingInstallation = errors.New("installation is missing")
)

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 Account added in v1.0.6

type Account struct {
	Login string `json:"login"`
}

type AnyEvent

type AnyEvent struct {
	Installation GithubInstallation `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, app GithubApp) (token string, err error)
	GetAppAndInstallationByOwner(ctx context.Context, repoOwner string) (app *GithubApp, installation *GithubInstallation, err error)
	GetAppAndInstallationByID(ctx context.Context, installationID int) (app *GithubApp, installation *GithubInstallation, err error)
	GetInstallationToken(ctx context.Context, app GithubApp, installation GithubInstallation) (accessToken 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)
	ConvertAppManifestCode(ctx context.Context, code string) (err error)
	GetApps(ctx context.Context) (apps []*GithubApp, err error)
	GetAppByID(ctx context.Context, id int) (app *GithubApp, err error)
	AddApp(ctx context.Context, app GithubApp) (err error)
	RemoveApp(ctx context.Context, app GithubApp) (err error)
	AddInstallation(ctx context.Context, installation GithubInstallation) (err error)
	RemoveInstallation(ctx context.Context, installation GithubInstallation) (err error)
}

Client is the interface for communicating with the github api

func NewClient

func NewClient(config *api.APIConfig, kubeClientset *kubernetes.Clientset, secretHelper crypt.SecretHelper) 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 GithubApp added in v1.0.6

type GithubApp struct {
	ID            int                   `json:"id"`
	Name          string                `json:"name"`
	Slug          string                `json:"slug"`
	PrivateKey    string                `json:"pem"`
	WebhookSecret string                `json:"webhook_secret"`
	ClientID      string                `json:"client_id"`
	ClientSecret  string                `json:"client_secret"`
	Installations []*GithubInstallation `json:"installations"`
}

type GithubInstallation added in v1.0.6

type GithubInstallation struct {
	ID            int                       `json:"id"`
	AppID         int                       `json:"app_id,omitempty"`
	Account       *Account                  `json:"account,omitempty"`
	Organizations []*contracts.Organization `json:"organizations,omitempty"`
}

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) AddApp added in v1.0.6

func (m *MockClient) AddApp(ctx context.Context, app GithubApp) error

AddApp mocks base method.

func (*MockClient) AddInstallation added in v1.0.6

func (m *MockClient) AddInstallation(ctx context.Context, installation GithubInstallation) error

AddInstallation mocks base method.

func (*MockClient) ConvertAppManifestCode added in v1.0.6

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

ConvertAppManifestCode mocks base method.

func (*MockClient) EXPECT

func (m *MockClient) EXPECT() *MockClientMockRecorder

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

func (*MockClient) GetAppAndInstallationByID added in v1.0.6

func (m *MockClient) GetAppAndInstallationByID(ctx context.Context, installationID int) (*GithubApp, *GithubInstallation, error)

GetAppAndInstallationByID mocks base method.

func (*MockClient) GetAppAndInstallationByOwner added in v1.0.6

func (m *MockClient) GetAppAndInstallationByOwner(ctx context.Context, repoOwner string) (*GithubApp, *GithubInstallation, error)

GetAppAndInstallationByOwner mocks base method.

func (*MockClient) GetAppByID added in v1.0.6

func (m *MockClient) GetAppByID(ctx context.Context, id int) (*GithubApp, error)

GetAppByID mocks base method.

func (*MockClient) GetApps added in v1.0.6

func (m *MockClient) GetApps(ctx context.Context) ([]*GithubApp, error)

GetApps mocks base method.

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, app GithubApp) (string, error)

GetGithubAppToken mocks base method.

func (*MockClient) GetInstallationToken

func (m *MockClient) GetInstallationToken(ctx context.Context, app GithubApp, installation GithubInstallation) (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.

func (*MockClient) RemoveApp added in v1.0.6

func (m *MockClient) RemoveApp(ctx context.Context, app GithubApp) error

RemoveApp mocks base method.

func (*MockClient) RemoveInstallation added in v1.0.6

func (m *MockClient) RemoveInstallation(ctx context.Context, installation GithubInstallation) error

RemoveInstallation mocks base method.

type MockClientMockRecorder

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

MockClientMockRecorder is the mock recorder for MockClient.

func (*MockClientMockRecorder) AddApp added in v1.0.6

func (mr *MockClientMockRecorder) AddApp(ctx, app interface{}) *gomock.Call

AddApp indicates an expected call of AddApp.

func (*MockClientMockRecorder) AddInstallation added in v1.0.6

func (mr *MockClientMockRecorder) AddInstallation(ctx, installation interface{}) *gomock.Call

AddInstallation indicates an expected call of AddInstallation.

func (*MockClientMockRecorder) ConvertAppManifestCode added in v1.0.6

func (mr *MockClientMockRecorder) ConvertAppManifestCode(ctx, code interface{}) *gomock.Call

ConvertAppManifestCode indicates an expected call of ConvertAppManifestCode.

func (*MockClientMockRecorder) GetAppAndInstallationByID added in v1.0.6

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

GetAppAndInstallationByID indicates an expected call of GetAppAndInstallationByID.

func (*MockClientMockRecorder) GetAppAndInstallationByOwner added in v1.0.6

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

GetAppAndInstallationByOwner indicates an expected call of GetAppAndInstallationByOwner.

func (*MockClientMockRecorder) GetAppByID added in v1.0.6

func (mr *MockClientMockRecorder) GetAppByID(ctx, id interface{}) *gomock.Call

GetAppByID indicates an expected call of GetAppByID.

func (*MockClientMockRecorder) GetApps added in v1.0.6

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

GetApps indicates an expected call of GetApps.

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, app interface{}) *gomock.Call

GetGithubAppToken indicates an expected call of GetGithubAppToken.

func (*MockClientMockRecorder) GetInstallationToken

func (mr *MockClientMockRecorder) GetInstallationToken(ctx, app, installation 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.

func (*MockClientMockRecorder) RemoveApp added in v1.0.6

func (mr *MockClientMockRecorder) RemoveApp(ctx, app interface{}) *gomock.Call

RemoveApp indicates an expected call of RemoveApp.

func (*MockClientMockRecorder) RemoveInstallation added in v1.0.6

func (mr *MockClientMockRecorder) RemoveInstallation(ctx, installation interface{}) *gomock.Call

RemoveInstallation indicates an expected call of RemoveInstallation.

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 GithubInstallation `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 GithubInstallation `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