bitbucketapi

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 bitbucketapi is a generated GoMock package.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidAuthorizationHeader = errors.New("invalid authorization header")
	ErrInvalidSigningAlgorithm    = errors.New("invalid signing algorithm")
	ErrInvalidToken               = errors.New("invalid token")
	ErrNoInstallations            = errors.New("no installations")
	ErrMissingApp                 = errors.New("app for key is missing")
	ErrMissingInstallation        = errors.New("installation for clientKey is missing")
	ErrMissingClaims              = errors.New("token has no claims")
)

Functions

func IsRepoSourceBitbucket

func IsRepoSourceBitbucket(repoSourceToCompare string) bool

IsRepoSourceBitbucket returns true if the repo source is from bitbucket

Types

type AccessToken

type AccessToken struct {
	AccessToken  string `json:"access_token"`
	Scopes       string `json:"scopes"`
	ExpiresIn    int    `json:"expires_in"`
	RefreshToken string `json:"refresh_token"`
	TokenType    string `json:"token_type"`
}

AccessToken represents a token to use for api requests

type Author

type Author struct {
	Name     string `json:"display_name"`
	Username string `json:"username"`
	Raw      string `json:"raw"`
}

Author represents a Bitbucket author

func (*Author) GetEmailAddress

func (u *Author) GetEmailAddress() string

GetEmailAddress returns the email address extracted from Author

func (*Author) GetName

func (u *Author) GetName() string

GetName returns the name extracted from Author

type BitbucketApp added in v1.0.6

type BitbucketApp struct {
	Key           string                      `json:"key"`
	Installations []*BitbucketAppInstallation `json:"installations"`
}

type BitbucketAppInstallation added in v1.0.2

type BitbucketAppInstallation struct {
	Key           string                    `json:"key"`
	BaseApiURL    string                    `json:"baseApiUrl"`
	ClientKey     string                    `json:"clientKey"`
	SharedSecret  string                    `json:"sharedSecret"`
	Workspace     *Workspace                `json:"workspace"`
	Organizations []*contracts.Organization `json:"organizations,omitempty"`
}

func (*BitbucketAppInstallation) GetWorkspaceUUID added in v1.0.2

func (ai *BitbucketAppInstallation) GetWorkspaceUUID() string

type Client

type Client interface {
	GetAccessTokenByInstallation(ctx context.Context, installation BitbucketAppInstallation) (accesstoken AccessToken, err error)
	GetAccessTokenBySlug(ctx context.Context, workspaceSlug string) (accesstoken AccessToken, err error)
	GetAccessTokenByUUID(ctx context.Context, workspaceUUID string) (accesstoken AccessToken, err error)
	GetAccessTokenByJWTToken(ctx context.Context, jwtToken string) (accesstoken AccessToken, err error)
	GetEstafetteManifest(ctx context.Context, accesstoken AccessToken, event RepositoryPushEvent) (valid bool, manifest string, err error)
	JobVarsFunc(ctx context.Context) func(ctx context.Context, repoSource, repoOwner, repoName string) (token string, err error)
	ValidateInstallationJWT(ctx context.Context, authorizationHeader string) (installation *BitbucketAppInstallation, err error)
	GenerateJWTBySlug(ctx context.Context, workspaceSlug string) (tokenString string, err error)
	GenerateJWTByUUID(ctx context.Context, workspaceUUID string) (tokenString string, err error)
	GenerateJWTByInstallation(ctx context.Context, installation BitbucketAppInstallation) (tokenString string, err error)
	GetApps(ctx context.Context) (apps []*BitbucketApp, err error)
	GetAppByKey(ctx context.Context, key string) (app *BitbucketApp, err error)
	GetInstallationBySlug(ctx context.Context, workspaceSlug string) (installation *BitbucketAppInstallation, err error)
	GetInstallationByUUID(ctx context.Context, workspaceUUID string) (installation *BitbucketAppInstallation, err error)
	GetInstallationByClientKey(ctx context.Context, clientKey string) (installation *BitbucketAppInstallation, err error)
	AddApp(ctx context.Context, app BitbucketApp) (err error)
	AddInstallation(ctx context.Context, installation BitbucketAppInstallation) (err error)
	RemoveInstallation(ctx context.Context, installation BitbucketAppInstallation) (err error)
	GetWorkspace(ctx context.Context, installation BitbucketAppInstallation) (workspace *Workspace, err error)
}

Client is the interface for communicating with the bitbucket api

func NewClient

func NewClient(config *api.APIConfig, kubeClientset *kubernetes.Clientset, secretHelper crypt.SecretHelper) Client

NewClient returns a new bitbucket.Client

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"`
	Date    string `json:"date"`
	Hash    string `json:"hash"`
	Message string `json:"message"`
}

Commit represents a Bitbucket commit

func (*Commit) GetCommitMessage

func (t *Commit) GetCommitMessage() string

GetCommitMessage extracts the commit message from the Commit Message field

type EventCheck added in v1.0.1

type EventCheck struct {
	Data       *EventCheckData `json:"data"`
	Repository *Repository     `json:"repository"`
}

EventCheck helps to check whether the payload is in new or old format

func (*EventCheck) GetFullRepository added in v1.0.1

func (ec *EventCheck) GetFullRepository() string

func (*EventCheck) GetRepository added in v1.0.1

func (ec *EventCheck) GetRepository() *Repository

type EventCheckData added in v1.0.1

type EventCheckData struct {
	Repository *Repository `json:"repository"`
}
type Link struct {
	Href string `json:"href"`
}

Link represents a single link for Bitbucket

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.2002

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

AddApp mocks base method.

func (*MockClient) AddInstallation added in v1.0.2

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

AddInstallation 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) GenerateJWTByInstallation added in v1.0.2

func (m *MockClient) GenerateJWTByInstallation(ctx context.Context, installation BitbucketAppInstallation) (string, error)

GenerateJWTByInstallation mocks base method.

func (*MockClient) GenerateJWTBySlug added in v1.0.2

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

GenerateJWTBySlug mocks base method.

func (*MockClient) GenerateJWTByUUID added in v1.0.2

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

GenerateJWTByUUID mocks base method.

func (*MockClient) GetAccessTokenByInstallation added in v1.0.2

func (m *MockClient) GetAccessTokenByInstallation(ctx context.Context, installation BitbucketAppInstallation) (AccessToken, error)

GetAccessTokenByInstallation mocks base method.

func (*MockClient) GetAccessTokenByJWTToken added in v1.0.2

func (m *MockClient) GetAccessTokenByJWTToken(ctx context.Context, jwtToken string) (AccessToken, error)

GetAccessTokenByJWTToken mocks base method.

func (*MockClient) GetAccessTokenBySlug added in v1.0.2

func (m *MockClient) GetAccessTokenBySlug(ctx context.Context, workspaceSlug string) (AccessToken, error)

GetAccessTokenBySlug mocks base method.

func (*MockClient) GetAccessTokenByUUID added in v1.0.2

func (m *MockClient) GetAccessTokenByUUID(ctx context.Context, workspaceUUID string) (AccessToken, error)

GetAccessTokenByUUID mocks base method.

func (*MockClient) GetAppByKey added in v1.0.2002

func (m *MockClient) GetAppByKey(ctx context.Context, key string) (*BitbucketApp, error)

GetAppByKey mocks base method.

func (*MockClient) GetApps added in v1.0.6

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

GetApps mocks base method.

func (*MockClient) GetEstafetteManifest

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

GetEstafetteManifest mocks base method.

func (*MockClient) GetInstallationByClientKey added in v1.0.6

func (m *MockClient) GetInstallationByClientKey(ctx context.Context, clientKey string) (*BitbucketAppInstallation, error)

GetInstallationByClientKey mocks base method.

func (*MockClient) GetInstallationBySlug added in v1.0.2

func (m *MockClient) GetInstallationBySlug(ctx context.Context, workspaceSlug string) (*BitbucketAppInstallation, error)

GetInstallationBySlug mocks base method.

func (*MockClient) GetInstallationByUUID added in v1.0.2

func (m *MockClient) GetInstallationByUUID(ctx context.Context, workspaceUUID string) (*BitbucketAppInstallation, error)

GetInstallationByUUID mocks base method.

func (*MockClient) GetWorkspace added in v1.0.2

func (m *MockClient) GetWorkspace(ctx context.Context, installation BitbucketAppInstallation) (*Workspace, error)

GetWorkspace 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) RemoveInstallation added in v1.0.2

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

RemoveInstallation mocks base method.

func (*MockClient) ValidateInstallationJWT added in v1.0.2

func (m *MockClient) ValidateInstallationJWT(ctx context.Context, authorizationHeader string) (*BitbucketAppInstallation, error)

ValidateInstallationJWT 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.2002

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

AddApp indicates an expected call of AddApp.

func (*MockClientMockRecorder) AddInstallation added in v1.0.2

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

AddInstallation indicates an expected call of AddInstallation.

func (*MockClientMockRecorder) GenerateJWTByInstallation added in v1.0.2

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

GenerateJWTByInstallation indicates an expected call of GenerateJWTByInstallation.

func (*MockClientMockRecorder) GenerateJWTBySlug added in v1.0.2

func (mr *MockClientMockRecorder) GenerateJWTBySlug(ctx, workspaceSlug interface{}) *gomock.Call

GenerateJWTBySlug indicates an expected call of GenerateJWTBySlug.

func (*MockClientMockRecorder) GenerateJWTByUUID added in v1.0.2

func (mr *MockClientMockRecorder) GenerateJWTByUUID(ctx, workspaceUUID interface{}) *gomock.Call

GenerateJWTByUUID indicates an expected call of GenerateJWTByUUID.

func (*MockClientMockRecorder) GetAccessTokenByInstallation added in v1.0.2

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

GetAccessTokenByInstallation indicates an expected call of GetAccessTokenByInstallation.

func (*MockClientMockRecorder) GetAccessTokenByJWTToken added in v1.0.2

func (mr *MockClientMockRecorder) GetAccessTokenByJWTToken(ctx, jwtToken interface{}) *gomock.Call

GetAccessTokenByJWTToken indicates an expected call of GetAccessTokenByJWTToken.

func (*MockClientMockRecorder) GetAccessTokenBySlug added in v1.0.2

func (mr *MockClientMockRecorder) GetAccessTokenBySlug(ctx, workspaceSlug interface{}) *gomock.Call

GetAccessTokenBySlug indicates an expected call of GetAccessTokenBySlug.

func (*MockClientMockRecorder) GetAccessTokenByUUID added in v1.0.2

func (mr *MockClientMockRecorder) GetAccessTokenByUUID(ctx, workspaceUUID interface{}) *gomock.Call

GetAccessTokenByUUID indicates an expected call of GetAccessTokenByUUID.

func (*MockClientMockRecorder) GetAppByKey added in v1.0.2002

func (mr *MockClientMockRecorder) GetAppByKey(ctx, key interface{}) *gomock.Call

GetAppByKey indicates an expected call of GetAppByKey.

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

func (mr *MockClientMockRecorder) GetInstallationByClientKey(ctx, clientKey interface{}) *gomock.Call

GetInstallationByClientKey indicates an expected call of GetInstallationByClientKey.

func (*MockClientMockRecorder) GetInstallationBySlug added in v1.0.2

func (mr *MockClientMockRecorder) GetInstallationBySlug(ctx, workspaceSlug interface{}) *gomock.Call

GetInstallationBySlug indicates an expected call of GetInstallationBySlug.

func (*MockClientMockRecorder) GetInstallationByUUID added in v1.0.2

func (mr *MockClientMockRecorder) GetInstallationByUUID(ctx, workspaceUUID interface{}) *gomock.Call

GetInstallationByUUID indicates an expected call of GetInstallationByUUID.

func (*MockClientMockRecorder) GetWorkspace added in v1.0.2

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

GetWorkspace indicates an expected call of GetWorkspace.

func (*MockClientMockRecorder) JobVarsFunc

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

JobVarsFunc indicates an expected call of JobVarsFunc.

func (*MockClientMockRecorder) RemoveInstallation added in v1.0.2

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

RemoveInstallation indicates an expected call of RemoveInstallation.

func (*MockClientMockRecorder) ValidateInstallationJWT added in v1.0.2

func (mr *MockClientMockRecorder) ValidateInstallationJWT(ctx, authorizationHeader interface{}) *gomock.Call

ValidateInstallationJWT indicates an expected call of ValidateInstallationJWT.

type Owner

type Owner struct {
	Type        string `json:"type"`
	UserName    string `json:"username"`
	DisplayName string `json:"display_name"`
}

Owner represents a Bitbucket owner

type PushEvent

type PushEvent struct {
	Changes []PushEventChange `json:"changes"`
}

PushEvent represents a Bitbucket push event push info

type PushEventChange

type PushEventChange struct {
	New       *PushEventChangeObject `json:"new,omitempty"`
	Old       *PushEventChangeObject `json:"old,omitempty"`
	Created   bool                   `json:"created"`
	Closed    bool                   `json:"closed"`
	Forced    bool                   `json:"forced"`
	Commits   []Commit               `json:"commits"`
	Truncated bool                   `json:"truncated"`
}

PushEventChange represents a Bitbucket push change

type PushEventChangeObject

type PushEventChangeObject struct {
	Type   string                      `json:"type"`
	Name   string                      `json:"name,omitempty"`
	Target PushEventChangeObjectTarget `json:"target"`
}

PushEventChangeObject represents the state of the reference after a push

type PushEventChangeObjectTarget

type PushEventChangeObjectTarget struct {
	Hash    string                            `json:"hash"`
	Author  PushEventChangeObjectTargetAuthor `json:"author"`
	Message string                            `json:"message"`
}

PushEventChangeObjectTarget represents the target of a change

func (*PushEventChangeObjectTarget) GetCommitMessage

func (t *PushEventChangeObjectTarget) GetCommitMessage() string

GetCommitMessage extracts the commit message from the Commit Message field

type PushEventChangeObjectTargetAuthor

type PushEventChangeObjectTargetAuthor struct {
	Name     string `json:"display_name"`
	Username string `json:"username"`
	Raw      string `json:"raw"`
}

PushEventChangeObjectTargetAuthor represents the author of a commit

func (*PushEventChangeObjectTargetAuthor) GetEmailAddress

func (u *PushEventChangeObjectTargetAuthor) GetEmailAddress() string

GetEmailAddress returns the email address extracted from PushEventChangeObjectTargetAuthorUser

type RepoDeletedEvent

type RepoDeletedEvent struct {
	Actor      Owner      `json:"actor"`
	Repository Repository `json:"repository"`
}

RepoDeletedEvent represents a Bitbucket repo:deleted event

func (*RepoDeletedEvent) GetRepoName

func (pe *RepoDeletedEvent) GetRepoName() string

GetRepoName returns the repository name

func (*RepoDeletedEvent) GetRepoOwner

func (pe *RepoDeletedEvent) GetRepoOwner() string

GetRepoOwner returns the repository owner

func (*RepoDeletedEvent) GetRepoSource

func (pe *RepoDeletedEvent) GetRepoSource() string

GetRepoSource returns the repository source

type RepoUpdatedChanges

type RepoUpdatedChanges struct {
	FullName RepoUpdatedChangesName `json:"full_name"`
}

RepoUpdatedChanges records changes to the repository name

type RepoUpdatedChangesName

type RepoUpdatedChangesName struct {
	Old string `json:"old"`
	New string `json:"new"`
}

RepoUpdatedChangesName records changes to the repository name

type RepoUpdatedEvent

type RepoUpdatedEvent struct {
	Changes RepoUpdatedChanges `json:"changes"`
}

RepoUpdatedEvent represents a Bitbucket repo:updated event

func (*RepoUpdatedEvent) GetNewRepoName

func (pe *RepoUpdatedEvent) GetNewRepoName() string

GetNewRepoName returns the repository name

func (*RepoUpdatedEvent) GetNewRepoOwner

func (pe *RepoUpdatedEvent) GetNewRepoOwner() string

GetNewRepoOwner returns the repository owner

func (*RepoUpdatedEvent) GetOldRepoName

func (pe *RepoUpdatedEvent) GetOldRepoName() string

GetOldRepoName returns the repository name

func (*RepoUpdatedEvent) GetOldRepoOwner

func (pe *RepoUpdatedEvent) GetOldRepoOwner() string

GetOldRepoOwner returns the repository owner

func (*RepoUpdatedEvent) GetRepoSource

func (pe *RepoUpdatedEvent) GetRepoSource() string

GetRepoSource returns the repository source

func (*RepoUpdatedEvent) IsValidRenameEvent

func (pe *RepoUpdatedEvent) IsValidRenameEvent() bool

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

type Repository

type Repository struct {
	Name      string          `json:"name"`
	FullName  string          `json:"full_name"`
	Owner     Owner           `json:"owner"`
	IsPrivate bool            `json:"is_private"`
	Scm       string          `json:"scm"`
	Links     RepositoryLinks `json:"links"`
	Workspace *Workspace      `json:"workspace"`
}

Repository represents a Bitbucket repository

type RepositoryLinks struct {
	HTML Link `json:"html"`
}

RepositoryLinks represents a collections of links for a Bitbucket repository

type RepositoryPushEvent

type RepositoryPushEvent struct {
	Actor      Owner      `json:"actor"`
	Repository Repository `json:"repository"`
	Push       PushEvent  `json:"push"`
}

RepositoryPushEvent represents a Bitbucket push event payload

func (*RepositoryPushEvent) GetRepoBranch

func (pe *RepositoryPushEvent) GetRepoBranch() string

GetRepoBranch returns the branch of the push event

func (*RepositoryPushEvent) GetRepoFullName

func (pe *RepositoryPushEvent) GetRepoFullName() string

GetRepoFullName returns the repository owner and name

func (*RepositoryPushEvent) GetRepoName

func (pe *RepositoryPushEvent) GetRepoName() string

GetRepoName returns the repository name

func (*RepositoryPushEvent) GetRepoOwner

func (pe *RepositoryPushEvent) GetRepoOwner() string

GetRepoOwner returns the repository owner

func (*RepositoryPushEvent) GetRepoRevision

func (pe *RepositoryPushEvent) GetRepoRevision() string

GetRepoRevision returns the revision of the push event

func (*RepositoryPushEvent) GetRepoSource

func (pe *RepositoryPushEvent) GetRepoSource() string

GetRepoSource returns the repository source

func (*RepositoryPushEvent) GetRepository

func (pe *RepositoryPushEvent) GetRepository() string

GetRepository returns the full path to the repository

type RepositoryPushEventEnvelope added in v1.0.1

type RepositoryPushEventEnvelope struct {
	Event string              `json:"event"`
	Data  RepositoryPushEvent `json:"data"`
}

RepositoryPushEventEnvelope represents a Bitbucket push event in new envelope

type Workspace added in v1.0.2

type Workspace struct {
	Slug string `json:"slug"`
	Name string `json:"name"`
	UUID string `json:"uuid"`
}

Jump to

Keyboard shortcuts

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