Documentation
¶
Overview ¶
Package bitbucketserver is a small client for Bitbucket Server and Data Center (REST /rest/api/1.0), authenticated with a personal access token. It is unrelated to Bitbucket Cloud (internal/bitbucketapp): different API, auth and webhook format. Repositories are addressed as "PROJECT/slug".
Index ¶
- func SplitRepo(repo string) (project, slug string, err error)
- type Account
- type Branch
- type Client
- func (c *Client) CreateRepoWebhook(ctx context.Context, instanceURL, token, repo, hookURL, secret string) error
- func (c *Client) CurrentUser(ctx context.Context, instanceURL, token string) (Account, error)
- func (c *Client) DefaultBranch(ctx context.Context, instanceURL, token, repo string) (string, error)
- func (c *Client) DeleteRepoWebhook(ctx context.Context, instanceURL, token, repo, hookURL string) error
- func (c *Client) GetRepo(ctx context.Context, instanceURL, token, repo string) (Repo, error)
- func (c *Client) ListBranches(ctx context.Context, instanceURL, token, repo string) ([]Branch, error)
- func (c *Client) ListRepos(ctx context.Context, instanceURL, token string, opts gitprovider.ListOptions) ([]Repo, gitprovider.ListResult, error)
- type Repo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Client ¶
Client talks to one Bitbucket Server instance per call; the instance URL is an argument because every install is self-hosted.
func NewClient ¶
func NewClient() *Client
NewClient returns a Client on the SSRF-guarded HTTP client, since instance URLs are operator supplied.
func (*Client) CreateRepoWebhook ¶
func (c *Client) CreateRepoWebhook(ctx context.Context, instanceURL, token, repo, hookURL, secret string) error
CreateRepoWebhook registers a repo:refs_changed webhook on "PROJECT/slug". The secret makes Bitbucket sign each delivery with X-Hub-Signature (sha256=).
func (*Client) CurrentUser ¶
CurrentUser resolves the token's user: whoami returns the login as plain text, then the users endpoint supplies the stable numeric id.
func (*Client) DefaultBranch ¶
func (c *Client) DefaultBranch(ctx context.Context, instanceURL, token, repo string) (string, error)
DefaultBranch returns the repository's default branch, or "" for an empty repository.
func (*Client) DeleteRepoWebhook ¶
func (c *Client) DeleteRepoWebhook(ctx context.Context, instanceURL, token, repo, hookURL string) error
DeleteRepoWebhook removes this control plane's webhook pointing at hookURL; it is a no-op when none exists.
func (*Client) GetRepo ¶
GetRepo looks up "PROJECT/slug" and asks the server for its default branch.
func (*Client) ListBranches ¶
func (c *Client) ListBranches(ctx context.Context, instanceURL, token, repo string) ([]Branch, error)
ListBranches lists the branches of "PROJECT/slug".
func (*Client) ListRepos ¶
func (c *Client) ListRepos(ctx context.Context, instanceURL, token string, opts gitprovider.ListOptions) ([]Repo, gitprovider.ListResult, error)
ListRepos lists repositories the token can see, following nextPageStart until the last page or MaxItems.