azuredevops

package
v0.9.5 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

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

View Source
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

func IsPushPayload(body []byte) bool

IsPushPayload reports whether body is an Azure DevOps git.push service hook delivery.

func OrgName

func OrgName(instanceURL string) string

OrgName returns the organization segment of an instance URL, or the host when there is none.

func ParsePushEvent

func ParsePushEvent(body []byte) (webhook.PushEvent, error)

ParsePushEvent decodes a git.push delivery into a webhook.PushEvent. The first branch update wins; tag pushes yield webhook.ErrPushEventFieldsMissing.

func SplitRepo

func SplitRepo(repo string) (project, name string, err error)

SplitRepo parses "PROJECT/repo" into its two names.

func VerifyBasicAuth

func VerifyBasicAuth(secret string, header http.Header) bool

VerifyBasicAuth checks the Authorization header of a service hook delivery against the shared secret in constant time. A missing or malformed header fails closed.

Types

type Account

type Account struct {
	ID    string
	Login string
}

Account is the user behind a personal access token.

type Branch

type Branch struct {
	Name      string
	CommitSHA string
}

Branch is one branch and its head commit.

type Client

type Client struct {
	HTTP *http.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

func (c *Client) CurrentUser(ctx context.Context, instanceURL, token string) (Account, error)

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) GetRepo

func (c *Client) GetRepo(ctx context.Context, instanceURL, token, repo string) (Repo, error)

GetRepo looks up "PROJECT/repo".

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.

Jump to

Keyboard shortcuts

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