bbcloud

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2019 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIDiff

type APIDiff struct {
	New struct {
		Path string `json:"path"`
	} `json:"new"`
}

Details of a single file changed

type Config

type Config struct {
	Username string
	Token    string
	Endpoint string
	Logger   logrus.FieldLogger
}

Connection details for talking with bitbucket cloud

type DiffStatResponse

type DiffStatResponse struct {
	PagedAPIResponse
	Diffs []APIDiff `json:"values"`
}

Response of getting diff details of a commit. Documentation: https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Busername%7D/%7Brepo_slug%7D/diffstat/%7Bspec%7D

type FileService

type FileService struct {
	BbcloudEndpoint string
	BbcloudToken    string
	BbcloudUsername string
	Logger          logrus.FieldLogger
	// contains filtered or unexported fields
}

FileService is for working with repositories

func (*FileService) DecodeURL

func (f *FileService) DecodeURL(url string) (org, repo, path, branch string)

DecodeURL takes a url and returns the org, repo, path and branch

func (*FileService) Download

func (f *FileService) Download(org, repo, path, branch string) (string, error)

Download downloads a file from Bitbucket Cloud. The API returns the file's contents as a paginated list of lines

func (*FileService) EncodeURL

func (f *FileService) EncodeURL(org, repo, path, branch string) string

EncodeURL returns the git url for a given org, repo, path and branch

type PagedAPIResponse

type PagedAPIResponse struct {
	PageLength    int `json:"pagelen"`
	CurrentPage   int `json:"page"`
	NumberOfPages int `json:"size"`
}

PagedAPIResponse contains the fields needed for paged APIs

type Push

type Push struct {
	Payload      WebhookPayload
	ChangedFiles []string
	Logger       logrus.FieldLogger
}

Information about what files changed in a push

func NewPush

func NewPush(payload WebhookPayload, cfg Config) (*Push, error)

Converts the raw webhook payload sent by Bitbucket Cloud, to an internal Push structure with the list of files changed.

func (*Push) Branch

func (p *Push) Branch() string

Branch returns the branch of the push

func (*Push) ContainsFile

func (p *Push) ContainsFile(file string) bool

ContainsFile checks to see if a given file is in the push.

func (*Push) Files

func (p *Push) Files() []string

Files returns a slice containing filenames that were added/modified

func (*Push) IsMaster

func (p *Push) IsMaster() bool

IsMaster detects if the branch is master.

func (*Push) Name

func (p *Push) Name() string

Name returns the name of the provider to be used in configuration

func (*Push) Org

func (p *Push) Org() string

Org returns the name of the project.

func (*Push) Repo

func (p *Push) Repo() string

Repo returns the name of the repo.

func (*Push) SetCommitStatus

func (p *Push) SetCommitStatus(s git.Status)

SetCommitStatus sets a commit status

type WebhookChange

type WebhookChange struct {
	New WebhookChangeComparison `json:"new"`
	Old WebhookChangeComparison `json:"old"`
}

Change details in a webhook payload

func (*WebhookChange) Branch

func (c *WebhookChange) Branch() string

Find the branch in the webhook payload

func (*WebhookChange) IsMaster

func (c *WebhookChange) IsMaster() bool

Find in the webhook payload if the change was done in "master" branch

type WebhookChangeComparison

type WebhookChangeComparison struct {
	Name   string              `json:"name"`
	Target WebhookChangeTarget `json:"target"`
}

type WebhookChangeTarget

type WebhookChangeTarget struct {
	Hash string `json:"hash"`
}

type WebhookPayload

type WebhookPayload struct {
	Repository WebhookRepository `json:"repository"`
	Push       WebhookPush       `json:"push"`
}

Payload received in a "push" type webhook

type WebhookProject

type WebhookProject struct {
	Key string `json:"key"`
}

type WebhookPush

type WebhookPush struct {
	Changes []WebhookChange `json:"changes"`
}

type WebhookRepository

type WebhookRepository struct {
	Name     string         `json:"name"`
	FullName string         `json:"full_name"`
	Project  WebhookProject `json:"project"`
}

Jump to

Keyboard shortcuts

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