bitbucket

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2016 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusPending = "INPROGRESS"
	StatusSuccess = "SUCCESSFUL"
	StatusFailure = "FAILED"
)
View Source
const (
	DescPending = "this build is pending"
	DescSuccess = "the build was successful"
	DescFailure = "the build failed"
	DescError   = "oops, something went wrong"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	Login string `json:"username"`
	Name  string `json:"display_name"`
	Type  string `json:"type"`
	Links Links  `json:"links"`
}

type AccountResp

type AccountResp struct {
	Page   int        `json:"page"`
	Pages  int        `json:"pagelen"`
	Size   int        `json:"size"`
	Next   string     `json:"next"`
	Values []*Account `json:"values"`
}

type Bitbucket

type Bitbucket struct {
	Client string
	Secret string
	Orgs   []string
	Open   bool
}

func Load

func Load(config string) *Bitbucket

func (*Bitbucket) Activate

func (bb *Bitbucket) Activate(u *model.User, r *model.Repo, k *model.Key, link string) error

Activate activates a repository by creating the post-commit hook and adding the SSH deploy key, if applicable.

func (*Bitbucket) Auth

func (bb *Bitbucket) Auth(token, secret string) (string, error)

Auth authenticates the session and returns the remote user login for the given token and secret

func (*Bitbucket) Deactivate

func (bb *Bitbucket) Deactivate(u *model.User, r *model.Repo, link string) error

Deactivate removes a repository by removing all the post-commit hooks which are equal to link and removing the SSH deploy key.

func (*Bitbucket) File added in v0.4.2

func (bb *Bitbucket) File(u *model.User, r *model.Repo, b *model.Build, f string) ([]byte, error)

File fetches a file from the remote repository and returns in string format.

func (*Bitbucket) Hook

func (bb *Bitbucket) Hook(r *http.Request) (*model.Repo, *model.Build, error)

Hook parses the post-commit hook from the Request body and returns the required data in a standard format.

func (*Bitbucket) Login

func (bb *Bitbucket) Login(res http.ResponseWriter, req *http.Request) (*model.User, bool, error)

Login authenticates the session and returns the remote user details.

func (*Bitbucket) Netrc

func (bb *Bitbucket) Netrc(u *model.User, r *model.Repo) (*model.Netrc, error)

Netrc returns a .netrc file that can be used to clone private repositories from a remote system.

func (*Bitbucket) Perm

func (bb *Bitbucket) Perm(u *model.User, owner, name string) (*model.Perm, error)

Perm fetches the named repository permissions from the remote system for the specified user.

func (*Bitbucket) Refresh

func (bb *Bitbucket) Refresh(user *model.User) (bool, error)

Refresh refreshes an oauth token and expiration for the given user. It returns true if the token was refreshed, false if the token was not refreshed, and error if it failed to refersh.

func (*Bitbucket) Repo

func (bb *Bitbucket) Repo(u *model.User, owner, name string) (*model.Repo, error)

Repo fetches the named repository from the remote system.

func (*Bitbucket) Repos

func (bb *Bitbucket) Repos(u *model.User) ([]*model.RepoLite, error)

Repos fetches a list of repos from the remote system.

func (*Bitbucket) Status

func (bb *Bitbucket) Status(u *model.User, r *model.Repo, b *model.Build, link string) error

Status sends the commit status to the remote system. An example would be the GitHub pull request status.

func (*Bitbucket) String added in v0.4.2

func (bb *Bitbucket) String() string

type BuildStatus added in v0.4.2

type BuildStatus struct {
	State string `json:"state"`
	Key   string `json:"key"`
	Name  string `json:"name,omitempty"`
	Url   string `json:"url"`
	Desc  string `json:"description,omitempty"`
}

type Client

type Client struct {
	*http.Client
}

func NewClient

func NewClient(client *http.Client) *Client

func NewClientToken

func NewClientToken(client, secret string, token *oauth2.Token) *Client

func (*Client) CreateHook

func (c *Client) CreateHook(owner, name string, hook *Hook) error

func (*Client) CreateStatus added in v0.4.2

func (c *Client) CreateStatus(owner, name, revision string, status *BuildStatus) error

func (*Client) DeleteHook

func (c *Client) DeleteHook(owner, name, id string) error

func (*Client) FindCurrent

func (c *Client) FindCurrent() (*Account, error)

func (*Client) FindHook

func (c *Client) FindHook(owner, name, id string) (*Hook, error)

func (*Client) FindRepo

func (c *Client) FindRepo(owner, name string) (*Repo, error)

func (*Client) FindSource

func (c *Client) FindSource(owner, name, revision, path string) (*Source, error)

func (*Client) ListEmail

func (c *Client) ListEmail() (*EmailResp, error)

func (*Client) ListHooks

func (c *Client) ListHooks(owner, name string, opts *ListOpts) (*HookResp, error)

func (*Client) ListRepos

func (c *Client) ListRepos(account string, opts *ListOpts) (*RepoResp, error)

func (*Client) ListReposAll

func (c *Client) ListReposAll(account string) ([]*Repo, error)

func (*Client) ListTeams

func (c *Client) ListTeams(opts *ListTeamOpts) (*AccountResp, error)

type Email

type Email struct {
	Email       string `json:"email"`
	IsConfirmed bool   `json:"is_confirmed"`
	IsPrimary   bool   `json:"is_primary"`
}

type EmailResp

type EmailResp struct {
	Page   int      `json:"page"`
	Pages  int      `json:"pagelen"`
	Size   int      `json:"size"`
	Next   string   `json:"next"`
	Values []*Email `json:"values"`
}

type Error

type Error struct {
	Status int
	Body   struct {
		Message string `json:"message"`
	} `json:"error"`
}

func (Error) Error

func (e Error) Error() string

type Hook

type Hook struct {
	Uuid   string   `json:"uuid,omitempty"`
	Desc   string   `json:"description"`
	Url    string   `json:"url"`
	Events []string `json:"events"`
	Active bool     `json:"active"`
}

type HookResp

type HookResp struct {
	Page   int     `json:"page"`
	Pages  int     `json:"pagelen"`
	Size   int     `json:"size"`
	Next   string  `json:"next"`
	Values []*Hook `json:"values"`
}
type Link struct {
	Href string `json:"href"`
	Name string `json:"name"`
}

type LinkClone

type LinkClone struct {
	Link
}
type Links struct {
	Avatar Link   `json:"avatar"`
	Html   Link   `json:"html"`
	Clone  []Link `json:"clone"`
}

type ListOpts

type ListOpts struct {
	Page    int
	PageLen int
}

func (*ListOpts) Encode

func (o *ListOpts) Encode() string

type ListTeamOpts

type ListTeamOpts struct {
	Page    int
	PageLen int
	Role    string
}

func (*ListTeamOpts) Encode

func (o *ListTeamOpts) Encode() string

type PullRequestHook

type PullRequestHook struct {
	Actor       Account `json:"actor"`
	Repo        Repo    `json:"repository"`
	PullRequest struct {
		ID      int       `json:"id"`
		Type    string    `json:"type"`
		Reason  string    `json:"reason"`
		Desc    string    `json:"description"`
		Title   string    `json:"title"`
		State   string    `json:"state"`
		Links   Links     `json:"links"`
		Created time.Time `json:"created_on"`
		Updated time.Time `json:"updated_on"`

		Source struct {
			Repo   Repo `json:"repsoitory"`
			Commit struct {
				Hash  string `json:"hash"`
				Links Links  `json:"links"`
			} `json:"commit"`
			Branch struct {
				Name string `json:"name"`
			} `json:"branch"`
		} `json:"source"`

		Dest struct {
			Repo   Repo `json:"repsoitory"`
			Commit struct {
				Hash  string `json:"hash"`
				Links Links  `json:"links"`
			} `json:"commit"`
			Branch struct {
				Name string `json:"name"`
			} `json:"branch"`
		} `json:"destination"`
	} `json:"pullrequest"`
}

type PushHook

type PushHook struct {
	Actor Account `json:"actor"`
	Repo  Repo    `json:"repository"`
	Push  struct {
		Changes []struct {
			New struct {
				Type   string `json:"type"`
				Name   string `json:"name"`
				Target struct {
					Type    string    `json:"type"`
					Hash    string    `json:"hash"`
					Message string    `json:"message"`
					Date    time.Time `json:"date"`
					Links   Links     `json:"links"`
					Author  struct {
						Raw  string  `json:"raw"`
						User Account `json:"user"`
					} `json:"author"`
				} `json:"target"`
			} `json:"new"`
		} `json:"changes"`
	} `json:"push"`
}

type Repo

type Repo struct {
	Owner     Account `json:"owner"`
	Name      string  `json:"name"`
	FullName  string  `json:"full_name"`
	Language  string  `json:"language"`
	IsPrivate bool    `json:"is_private"`
	Scm       string  `json:"scm"`
	Desc      string  `json:"desc"`
	Links     Links   `json:"links"`
}

type RepoResp

type RepoResp struct {
	Page   int     `json:"page"`
	Pages  int     `json:"pagelen"`
	Size   int     `json:"size"`
	Next   string  `json:"next"`
	Values []*Repo `json:"values"`
}

type Source

type Source struct {
	Node string `json:"node"`
	Path string `json:"path"`
	Data string `json:"data"`
	Size int64  `json:"size"`
}

Jump to

Keyboard shortcuts

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