Documentation
¶
Overview ¶
Package azuredevops is a small client for Azure DevOps Services and Server (REST api 7.1), authenticated with a personal access token. An instance URL is the organization root, https://dev.azure.com/ORG, and repositories are addressed as "PROJECT/repo".
Index ¶
- Constants
- func IsPushPayload(body []byte) bool
- func OrgName(instanceURL string) string
- func ParsePushEvent(body []byte) (webhook.PushEvent, error)
- func SplitRepo(repo string) (project, name string, err error)
- func VerifyBasicAuth(secret string, header http.Header) bool
- 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) 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 ¶
const (
// WebhookUser is the basic-auth user the service hook sends; the password is the shared secret.
WebhookUser = "webhook"
)
Variables ¶
This section is empty.
Functions ¶
func IsPushPayload ¶
IsPushPayload reports whether body is an Azure DevOps git.push service hook delivery.
func OrgName ¶
OrgName returns the organization segment of an instance URL, or the host when there is none.
func ParsePushEvent ¶
ParsePushEvent decodes a git.push delivery into a webhook.PushEvent. The first branch update wins; tag pushes yield webhook.ErrPushEventFieldsMissing.
Types ¶
type Client ¶
Client talks to one organization per call; the URL is an argument because Azure DevOps Server installs are 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 subscribes a git.push service hook for one repository. Service hooks cannot HMAC-sign, so the secret rides as the basic-auth password.
func (*Client) CurrentUser ¶
CurrentUser resolves the token's user from the organization's connectionData. The id is prefixed with the organization so one person can connect several orgs.
func (*Client) DeleteRepoWebhook ¶
func (c *Client) DeleteRepoWebhook(ctx context.Context, instanceURL, token, repo, hookURL string) error
DeleteRepoWebhook removes the push subscription pointing at hookURL; it is a no-op when none exists.
func (*Client) ListBranches ¶
func (c *Client) ListBranches(ctx context.Context, instanceURL, token, repo string) ([]Branch, error)
ListBranches lists the branches of "PROJECT/repo".
func (*Client) ListRepos ¶
func (c *Client) ListRepos(ctx context.Context, instanceURL, token string, opts gitprovider.ListOptions) ([]Repo, gitprovider.ListResult, error)
ListRepos lists the repositories of every project in the organization. The endpoint is not paged, so MaxItems only truncates the result.
type Repo ¶
type Repo struct {
ID string
FullName string
Name string
Private bool
DefaultBranch string
CloneURL string
WebURL string
// ProjectID is the project GUID, which service hook subscriptions require.
ProjectID string
}
Repo is one repository, reduced to what the picker and source setup need.