bitbucket

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2018 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultCallbackURL = "http://ec2-34-212-13-136.us-west-2.compute.amazonaws.com:8088"
View Source
const DefaultRepoBaseURL = "https://api.bitbucket.org/2.0/repositories/%v"
View Source
const TokenUrl = "https://bitbucket.org/site/oauth2/access_token"

const V1RepoBaseURL = "https://api.bitbucket.org/1.0/repositories/%v"

Variables

This section is empty.

Functions

func GetBitbucketClient

func GetBitbucketClient(cfg *pb.VCSCreds) (models.VCSHandler, string, error)

Returns VCS handler for pulling source code and auth token if exists (auth token is needed for code download)

func GetBitbucketFromHttpClient

func GetBitbucketFromHttpClient(cli *http.Client) models.VCSHandler

func GetBitbucketHandler

func GetBitbucketHandler(adminConfig *pb.VCSCreds, client ocenet.HttpClient) models.VCSHandler

TODO: callback url is set as env. variable on admin, or passed in via command line GetBitbucketHandler returns a Bitbucket handler referenced by VCSHandler interface

Types

type BBTranslate

type BBTranslate struct {
	Unmarshaler jsonpb.Unmarshaler
}

func GetTranslator

func GetTranslator() *BBTranslate

func (*BBTranslate) TranslatePR

func (bb *BBTranslate) TranslatePR(reader io.Reader) (*pb.PullRequest, error)

func (*BBTranslate) TranslatePush

func (bb *BBTranslate) TranslatePush(reader io.Reader) (*pb.Push, error)

TranslatePush will convert a push event from bitbucket into the VCS-generic push object.

type Bitbucket

type Bitbucket struct {
	CallbackURL string
	RepoBaseURL string
	Client      ocenet.HttpClient
	Marshaler   jsonpb.Marshaler
	Unmarshaler jsonpb.Unmarshaler
	// contains filtered or unexported fields
}

Bitbucket is a bitbucket handler responsible for finding build files and registering webhooks for necessary repositories

func (*Bitbucket) CreateWebhook

func (bb *Bitbucket) CreateWebhook(webhookURL string) error

CreateWebhook will create webhook at specified webhook url

func (*Bitbucket) FindWebhooks

func (bb *Bitbucket) FindWebhooks(getWebhookURL string) bool

recursively iterates over all webhooks and returns true (matches our callback urls) if one already exists

func (*Bitbucket) GetAllBranchesLastCommitData

func (bb *Bitbucket) GetAllBranchesLastCommitData(acctRepo string) ([]*pb.BranchHistory, error)

func (*Bitbucket) GetAllCommits

func (bb *Bitbucket) GetAllCommits(acctRepo string, branch string) ([]*pb.Commit, error)

GetAllCommits /2.0/repositories/{username}/{repo_slug}/commits

func (*Bitbucket) GetBaseURL

func (bb *Bitbucket) GetBaseURL() string

func (*Bitbucket) GetBranchLastCommitData

func (bb *Bitbucket) GetBranchLastCommitData(acctRepo, branch string) (hist *pb.BranchHistory, err error)

func (*Bitbucket) GetCallbackURL

func (bb *Bitbucket) GetCallbackURL() string

GetCallbackURL is a getter for retrieving callbackURL for bitbucket webhooks

func (*Bitbucket) GetChangedFiles added in v0.7.3

func (bb *Bitbucket) GetChangedFiles(acctRepo, latestHash, earliestHash string) (changedFiles []string, err error)

GetChangedFiles will get the list of files that have changed between commits. If earliestHash is not passed, then the diff list will be off of just the changed files in the latestHash. If earliesthash is passed, then it will return the changeset similar to git diff --name-only <latestHash>..<earliestHash>

func (*Bitbucket) GetClient

func (bb *Bitbucket) GetClient() ocenet.HttpClient

func (*Bitbucket) GetCommit added in v0.7.3

func (bb *Bitbucket) GetCommit(acctRepo, hash string) (*pb.Commit, error)

func (*Bitbucket) GetCommitLog

func (bb *Bitbucket) GetCommitLog(acctRepo, branch, lastHash string) ([]*pb.Commit, error)

GetCommitLog will return a list of Commits, starting with the most recent and ending at the lastHash value. If the lastHash commit value is never found, will return an error.

func (*Bitbucket) GetFile

func (bb *Bitbucket) GetFile(filePath string, fullRepoName string, commitHash string) (bytez []byte, err error)

Get File in repo at a certain commit. filepath: string filepath relative to root of repo fullRepoName: string account_name/repo_name as it is returned in the Bitbucket api Repo Source `full_name` commitHash: string git hash for revision number

func (*Bitbucket) GetPRCommits

func (bb *Bitbucket) GetPRCommits(url string) ([]*pb.Commit, error)
func (bb *Bitbucket) GetRepoLinks(acctRepo string) (*pb.Links, error)

func (*Bitbucket) GetVcsType added in v0.8.0

func (bb *Bitbucket) GetVcsType() pb.SubCredType

func (*Bitbucket) PostPRComment

func (bb *Bitbucket) PostPRComment(acctRepo, prId, hash string, fail bool, buildId int64) error

func (*Bitbucket) SetBaseURL

func (bb *Bitbucket) SetBaseURL(baseURL string)

func (*Bitbucket) SetCallbackURL

func (bb *Bitbucket) SetCallbackURL(callbackURL string)

SetCallbackURL sets callback urls to be used for webhooks

func (*Bitbucket) Walk

func (bb *Bitbucket) Walk() error

Walk iterates over all repositories and creates webhook if one doesn't exist. Will only work if client has been setup

Jump to

Keyboard shortcuts

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