gitlab

package
v1.8.1 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const Gitlabdotcom = "https://gitlab.com"
View Source
const SettingButtonsTeam = "team"

Variables

View Source
var (
	ErrNotFound        = errors.New("not found")
	ErrForbidden       = errors.New("access forbidden")
	ErrPrivateResource = errors.New("private resource")
)

Errors returned by this package.

Functions

func PrettyError added in v1.5.0

func PrettyError(err error) error

PrettyError returns an err in a better readable way.

Types

type AddWebhookOptions added in v1.2.0

type AddWebhookOptions struct {
	URL                      string
	ConfidentialNoteEvents   bool
	PushEvents               bool
	IssuesEvents             bool
	ConfidentialIssuesEvents bool
	MergeRequestsEvents      bool
	TagPushEvents            bool
	NoteEvents               bool
	JobEvents                bool
	PipelineEvents           bool
	WikiPageEvents           bool
	EnableSSLVerification    bool
	Token                    string
}

AddWebhookOptions is a paramater object with options for creating a project or group hook.

type Gitlab

type Gitlab interface {
	GitlabConnect(token oauth2.Token) (*internGitlab.Client, error)
	GetCurrentUser(ctx context.Context, userID string, token oauth2.Token) (*UserInfo, error)
	GetUserDetails(ctx context.Context, user *UserInfo, token *oauth2.Token) (*internGitlab.User, error)
	GetProject(ctx context.Context, user *UserInfo, token *oauth2.Token, owner, repo string) (*internGitlab.Project, error)
	GetYourPrDetails(ctx context.Context, log logger.Logger, user *UserInfo, token *oauth2.Token, prList []*PRDetails) ([]*PRDetails, error)
	GetReviews(ctx context.Context, user *UserInfo, client *internGitlab.Client) ([]*MergeRequest, error)
	GetYourAssignedPrs(ctx context.Context, user *UserInfo, client *internGitlab.Client) ([]*MergeRequest, error)
	GetLHSData(ctx context.Context, user *UserInfo, token *oauth2.Token) (*LHSContent, error)
	GetYourAssignedIssues(ctx context.Context, user *UserInfo, client *internGitlab.Client) ([]*Issue, error)
	GetToDoList(ctx context.Context, user *UserInfo, client *internGitlab.Client) ([]*internGitlab.Todo, error)
	GetProjectHooks(ctx context.Context, user *UserInfo, token *oauth2.Token, owner string, repo string) ([]*WebhookInfo, error)
	GetGroupHooks(ctx context.Context, user *UserInfo, token *oauth2.Token, owner string) ([]*WebhookInfo, error)
	NewProjectHook(ctx context.Context, user *UserInfo, token *oauth2.Token, projectID interface{}, projectHookOptions *AddWebhookOptions) (*WebhookInfo, error)
	NewGroupHook(ctx context.Context, user *UserInfo, token *oauth2.Token, groupName string, groupHookOptions *AddWebhookOptions) (*WebhookInfo, error)
	TriggerProjectPipeline(userInfo *UserInfo, token *oauth2.Token, projectID string, ref string) (*PipelineInfo, error)
	// ResolveNamespaceAndProject accepts full path to User, Group or namespaced Project and returns corresponding
	// namespace and project name.
	//
	// ErrNotFound will be returned if no resource can be found.
	// If allowPrivate is set to false, and resolved group/project is private, ErrPrivateResource will be returned.
	ResolveNamespaceAndProject(
		ctx context.Context,
		userInfo *UserInfo,
		token *oauth2.Token,
		fullPath string,
		allowPrivate bool,
	) (namespace string, project string, err error)
}

Gitlab is a client to call GitLab api see New() to build one

func New

func New(gitlabURL string, gitlabGroup string, checkGroup func(projectNameWithGroup string) error) Gitlab

New return a client to call GitLab API

type Issue added in v1.7.0

type Issue struct {
	*internGitlab.Issue
	LabelsWithDetails []*internGitlab.Label `json:"labels_with_details,omitempty"`
}

type LHSContent added in v1.8.0

type LHSContent struct {
	AssignedPRs    []*MergeRequest      `json:"yourAssignedPrs"`
	Reviews        []*MergeRequest      `json:"reviews"`
	AssignedIssues []*Issue             `json:"yourAssignedIssues"`
	Todos          []*internGitlab.Todo `json:"todos"`
}

type MergeRequest added in v1.7.0

type MergeRequest struct {
	*internGitlab.MergeRequest
	LabelsWithDetails []*internGitlab.Label `json:"labels_with_details,omitempty"`
}

type PRDetails added in v1.7.0

type PRDetails struct {
	IID          int                           `json:"iid"`
	Status       *internGitlab.BuildStateValue `json:"status"`
	SHA          string                        `json:"sha"`
	NumApprovers int                           `json:"num_approvers"`
	ProjectID    int                           `json:"project_id"`
}

type PipelineInfo added in v1.6.0

type PipelineInfo struct {
	PipelineID int
	Status     string
	Ref        string
	WebURL     string
	SHA        string
	User       string
}

PipelineInfo is the struct describing the status of a running pipeline.

type PipelineJobInfo added in v1.6.0

type PipelineJobInfo struct {
	JobID  int
	Status string
	Ref    string
	WebURL string
	User   string
}

PipelineJobInfo is the struct describing the status of a running Job which is part of a pipeline

type Scope added in v1.2.0

type Scope int

Scope identifies the scope of a webhook

const (
	// Group is a type for group hooks
	Group Scope = iota
	// Project is a type for project hooks
	Project
)

func (Scope) String added in v1.2.0

func (s Scope) String() string

type UserInfo added in v1.3.0

type UserInfo struct {
	UserID              string
	GitlabUsername      string
	GitlabUserID        int
	LastToDoPostAt      int64
	Settings            *UserSettings
	AllowedPrivateRepos bool
}

type UserSettings

type UserSettings struct {
	SidebarButtons string `json:"sidebar_buttons"`
	DailyReminder  bool   `json:"daily_reminder"`
	Notifications  bool   `json:"notifications"`
}

type WebhookInfo added in v1.2.0

type WebhookInfo struct {
	ID                       int
	URL                      string
	ConfidentialNoteEvents   bool
	PushEvents               bool
	IssuesEvents             bool
	ConfidentialIssuesEvents bool
	MergeRequestsEvents      bool
	TagPushEvents            bool
	NoteEvents               bool
	JobEvents                bool
	PipelineEvents           bool
	WikiPageEvents           bool
	EnableSSLVerification    bool
	CreatedAt                *time.Time
	Scope                    Scope
}

WebhookInfo Provides information about group or project hooks.

func (*WebhookInfo) String added in v1.2.0

func (w *WebhookInfo) String() string

String produces a multiline bulleted string for displaying webhook information.

Directories

Path Synopsis
Package mock_gitlab is a generated GoMock package.
Package mock_gitlab is a generated GoMock package.

Jump to

Keyboard shortcuts

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