gitlab

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2025 License: MPL-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package gitlab provides a SDK and helpers for the gitlab provider.

Index

Constants

View Source
const DefaultTimeout = 60 * time.Second

DefaultTimeout is the default timeout for Gitlab API requests.

View Source
const (
	// ErrNotFound indicates the resource does not exists.
	ErrNotFound errors.Kind = "resource not found (HTTP Status: 404)"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// BaseURL is the base URL used to construct the final URL of endpoints.
	// If not set, it uses CI_API_V4_URL environment variable.
	BaseURL string

	// HTTPClient sets the HTTP client used and then allows for advanced
	// connection reuse schemes. If not set, a new http.Client is used.
	HTTPClient *http.Client

	// Token is the Gitlab token (usually provided by the GITLAB_TOKEN environment variable.
	Token string

	ProjectID int64
	Group     string
	Project   string
}

Client is a Gitlab API HTTP client wrapper.

func (*Client) MRForCommit

func (c *Client) MRForCommit(ctx context.Context, sha string) (mr MR, found bool, err error)

MRForCommit returns the with first Merge Requests associated with the provided commit SHA.

func (*Client) MRParticipants

func (c *Client) MRParticipants(ctx context.Context, mrIID int) ([]User, error)

MRParticipants returns the the participants for the given MR.

func (*Client) MRReviewers

func (c *Client) MRReviewers(ctx context.Context, mrIID int) ([]MRReviewer, error)

MRReviewers returns the the reviewers for the given MR.

type MR

type MR struct {
	ID                  int      `json:"id"`
	IID                 int      `json:"iid"`
	ProjectID           int      `json:"project_id"`
	Title               string   `json:"title"`
	Description         string   `json:"description,omitempty"`
	State               string   `json:"state"`
	CreatedAt           string   `json:"created_at,omitempty"`
	UpdatedAt           string   `json:"updated_at,omitempty"`
	TargetBranch        string   `json:"target_branch"`
	SourceBranch        string   `json:"source_branch"`
	Upvotes             int      `json:"upvotes"`
	Downvotes           int      `json:"downvotes"`
	Author              User     `json:"author"`
	Labels              []string `json:"labels"`
	Draft               bool     `json:"draft"`
	WorkInProgress      bool     `json:"work_in_progress"`
	SHA                 string   `json:"sha"`
	MergeStatus         string   `json:"merge_status"`
	DetailedMergeStatus string   `json:"detailed_merge_status"`
	WebURL              string   `json:"web_url"`
	Assignees           []User   `json:"assignees"`
}

MR is a Gitlab Merge Request.

type MRReviewer

type MRReviewer struct {
	User      *User      `json:"user"`
	State     string     `json:"state"`
	CreatedAt *time.Time `json:"created_at"`
}

MRReviewer is a Merge Request reviewer.

type MRs

type MRs []MR

MRs is a list of Gitlab Merge Requests.

type User

type User struct {
	ID        int    `json:"id"`
	Username  string `json:"username"`
	Name      string `json:"name"`
	WebURL    string `json:"web_url"`
	AvatarURL string `json:"avatar_url"`
	State     string `json:"state"`
}

User is a Gitlab user.

Jump to

Keyboard shortcuts

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