lab

package
v0.17.3-0...-2a221cc Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2020 License: CC0-1.0 Imports: 15 Imported by: 0

Documentation

Overview

Package lab is an internal wrapper for the go-gitlab package

Most functions serve to expose debug logging if set and accept a project name string over an ID.

Index

Constants

View Source
const (
	TmplMR    = "merge_request_templates/default.md"
	TmplIssue = "issue_templates/default.md"
)

Defines filepath for default GitLab templates

Variables

View Source
var ErrProjectNotFound = errors.New("gitlab project not found, verify you have access to the requested resource")

ErrProjectNotFound is returned when a GitLab project cannot be found.

Functions

func BranchPushed

func BranchPushed(pid interface{}, branch string) bool

BranchPushed checks if a branch exists on a GitLab project

func BranchUnprotect

func BranchUnprotect(pid interface{}, branch string) error

BraBranchUnprotect unprotects branch

func CICancel

func CICancel(pid interface{}, jobID int) (*gitlab.Job, error)

CICancel cancels a job for a given project by its ID.

func CICreate

func CICreate(pid interface{}, opts *gitlab.CreatePipelineOptions) (*gitlab.Pipeline, error)

CICreate creates a pipeline for given ref

func CIJobs

func CIJobs(pid interface{}, branch string) ([]*gitlab.Job, error)

CIJobs returns a list of jobs in a pipeline for a given sha. The jobs are returned sorted by their CreatedAt time

func CIPlayOrRetry

func CIPlayOrRetry(pid interface{}, jobID int, status string) (*gitlab.Job, error)

CIPlayOrRetry runs a job either by playing it for the first time or by retrying it based on the currently known job state

func CITrace

func CITrace(pid interface{}, branch, name string) (io.Reader, *gitlab.Job, error)

CITrace searches by name for a job and returns its trace file. The trace is static so may only be a portion of the logs if the job is till running. If no name is provided job is picked using the first available: 1. Last Running Job 2. First Pending Job 3. Last Job in Pipeline

func CITrigger

func CITrigger(pid interface{}, opts gitlab.RunPipelineTriggerOptions) (*gitlab.Pipeline, error)

CITrigger triggers a pipeline for given ref

func FindProject

func FindProject(project string) (*gitlab.Project, error)

FindProject looks up the Gitlab project. If the namespace is not provided in the project string it will search for projects in the users namespace

func Fork

func Fork(project string) (string, error)

Fork creates a user fork of a GitLab project

func GetProject

func GetProject(projectID interface{}) (*gitlab.Project, error)

GetProject looks up a Gitlab project by ID.

func Host

func Host() string

Host exposes the GitLab scheme://hostname used to interact with the API

func Init

func Init(_host, _user, _token string, allowInsecure bool)

Init initializes a gitlab client for use throughout lab.

func InitWithCustomCA

func InitWithCustomCA(_host, _user, _token, caFile string) error

func IssueClose

func IssueClose(pid interface{}, id int) error

IssueClose closes an issue on a GitLab project

func IssueCreate

func IssueCreate(project string, opts *gitlab.CreateIssueOptions) (string, error)

IssueCreate opens a new issue on a GitLab project

func IssueCreateNote

func IssueCreateNote(project string, issueNum int, opts *gitlab.CreateIssueNoteOptions) (string, error)

IssueCreateNote creates a new note on an issue and returns the note URL

func IssueGet

func IssueGet(project string, issueNum int) (*gitlab.Issue, error)

IssueGet retrieves the issue information from a GitLab project

func IssueList

func IssueList(project string, opts gitlab.ListProjectIssuesOptions, n int) ([]*gitlab.Issue, error)

IssueList gets a list of issues on a GitLab Project

func IssueListDiscussions

func IssueListDiscussions(project string, issueNum int) ([]*gitlab.Discussion, error)

IssueListDiscussions retrieves the discussions (aka notes & comments) for an issue

func IssueUpdate

func IssueUpdate(project string, issueNum int, opts *gitlab.UpdateIssueOptions) (string, error)

IssueUpdate edits an issue on a GitLab project

func LabelList

func LabelList(project string) ([]*gitlab.Label, error)

LabelList gets a list of labels on a GitLab Project

func Labels

func Labels(labels []string) *gitlab.Labels

Labels converts a []string into a non-nil *gitlab.Labels.

func Lint

func Lint(content string) (bool, error)

Lint validates .gitlab-ci.yml contents

func LoadGitLabTmpl

func LoadGitLabTmpl(tmplName string) string

LoadGitLabTmpl loads gitlab templates for use in creating Issues and MRs

https://gitlab.com/help/user/project/description_templates.md#setting-a-default-template-for-issues-and-merge-requests

func MRApprove

func MRApprove(pid interface{}, id int) error

MRApprove approves an mr on a GitLab project

func MRClose

func MRClose(pid interface{}, id int) error

MRClose closes an mr on a GitLab project

func MRCreate

func MRCreate(project string, opts *gitlab.CreateMergeRequestOptions) (string, error)

MRCreate opens a merge request on GitLab

func MRCreateNote

func MRCreateNote(project string, mrNum int, opts *gitlab.CreateMergeRequestNoteOptions) (string, error)

MRCreateNote adds a note to a merge request on GitLab

func MRGet

func MRGet(project string, mrNum int) (*gitlab.MergeRequest, error)

MRGet retrieves the merge request from GitLab project

func MRList

MRList lists the MRs on a GitLab project

func MRMerge

func MRMerge(pid interface{}, id int) error

MRMerge merges an mr on a GitLab project

func MRRebase

func MRRebase(pid interface{}, id int) error

MRRebase merges an mr on a GitLab project

func MRThumbDown

func MRThumbDown(pid interface{}, id int) error

MRThumbDown places a thumb up/down on a merge request

func MRThumbUp

func MRThumbUp(pid interface{}, id int) error

MRThumbUp places a thumb up/down on a merge request

func NamespaceSearch

func NamespaceSearch(query string) ([]*gitlab.Namespace, error)

NamespaceSearch searches for a namespace on GitLab

func ProjectCreate

func ProjectCreate(opts *gitlab.CreateProjectOptions) (*gitlab.Project, error)

ProjectCreate creates a new project on GitLab

func ProjectDelete

func ProjectDelete(pid interface{}) error

ProjectDelete creates a new project on GitLab

func ProjectEdit

func ProjectEdit(pid interface{}, opts *gitlab.EditProjectOptions) (*gitlab.Project, error)

ProjectDelete edits a project on GitLab

func ProjectList

func ProjectList(opts gitlab.ListProjectsOptions, n int) ([]*gitlab.Project, error)

ProjectList gets a list of projects on GitLab

func ProjectSnippetCreate

func ProjectSnippetCreate(pid interface{}, opts *gitlab.CreateProjectSnippetOptions) (*gitlab.Snippet, error)

ProjectSnippetCreate creates a snippet in a project

func ProjectSnippetDelete

func ProjectSnippetDelete(pid interface{}, id int) error

ProjectSnippetDelete deletes a project snippet

func ProjectSnippetList

func ProjectSnippetList(pid interface{}, opts gitlab.ListProjectSnippetsOptions, n int) ([]*gitlab.Snippet, error)

ProjectSnippetList lists snippets on a project

func SnippetCreate

func SnippetCreate(opts *gitlab.CreateSnippetOptions) (*gitlab.Snippet, error)

SnippetCreate creates a personal snippet

func SnippetDelete

func SnippetDelete(id int) error

SnippetDelete deletes a personal snippet

func SnippetList

func SnippetList(opts gitlab.ListSnippetsOptions, n int) ([]*gitlab.Snippet, error)

SnippetList lists snippets on a project

func User

func User() string

User exposes the configured GitLab user

func UserIDFromUsername

func UserIDFromUsername(username string) (int, error)

UserIDFromUsername returns the associated Users ID in GitLab. This is useful for API calls that allow you to reference a user, but only by ID.

Types

This section is empty.

Jump to

Keyboard shortcuts

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