helper

package
v0.0.0-...-3a36f6d Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2020 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAPIError = errors.New("API error")
View Source
var ErrFeature = errors.New("required feature is not supported by the affected GitLab instance")
View Source
var ErrGit = errors.New("git command failed")
View Source
var ErrNoInstance = errors.New("no instance matched")
View Source
var ErrNotManual = errors.New("job to be triggered is not a manual job or already running")

Functions

func ColorStatus

func ColorStatus(in string) string

func CommitBody

func CommitBody(commithash string) (string, error)

* CommitSubject returns the body of a commit

func CommitSubject

func CommitSubject(commithash string) (string, error)

* CommitSubject returns the subject of a commit

func Confirm

func Confirm() bool

*

  • Returns true if the user confirmed, false otherwise.
  • You need to print the query string yourself!

func CurrentBranch

func CurrentBranch() (string, error)

* CurrentBranch returns the current branch of the current repository

func CurrentCommitHash

func CurrentCommitHash() (string, error)

* CurrentCommitHash returns the current commit of the current repository

func CurrentCommitHashOnTrackingUpstream

func CurrentCommitHashOnTrackingUpstream() (string, error)

* CurrentCommitHashOnTrackingUpstream returns the current commit of the current tracking upstream

func CurrentTrackingBranch

func CurrentTrackingBranch() (string, error)

func EditInEditor

func EditInEditor(source string) (out string, err error)

func FindJobIdByName

func FindJobIdByName(jobs []Job, name string) int64

func GETEndpointRaw

func GETEndpointRaw(instance *config.Instance, endpoint string) (resp *http.Response, err error)

* GETEndpoint is a helper to execute authorized GET calls to the API of the provided instance.

func GetRemoteURLByName

func GetRemoteURLByName(name string) (string, error)

func Git

func Git(arg ...string) (string, error)

func GitRoot

func GitRoot() (string, error)

* GitRoot returns the root dir of the current repository

func InstanceForHostname

func InstanceForHostname(conf *config.Config, hostname string) (*config.Instance, error)

func InstanceForRepo

func InstanceForRepo(conf *config.Config, repoPath string) (*config.Instance, string, error)

* InstanceForRepo returns the instance from the configuration that is applicable fot the repository passed in.

func InstanceForURL

func InstanceForURL(conf *config.Config, url string) (instance *config.Instance, returnUrl string, err error)

* InstanceForRepo returns the instance and URL path for the url passed in.

func InstanceSupportsFeature

func InstanceSupportsFeature(instance *config.Instance, features ...string) bool

func InstanceVersion

func InstanceVersion(instance *config.Instance) (version string, err error)

func IsGitVersionGreaterOrEqual

func IsGitVersionGreaterOrEqual(version string) bool

func NewAuthenticatedAPIRequest

func NewAuthenticatedAPIRequest(instance *config.Instance, method string, endpoint string, body io.Reader) (req *http.Request, err error)

func NewAuthenticatedJSONAPIRequest

func NewAuthenticatedJSONAPIRequest(instance *config.Instance, method string, endpoint string, payload interface{}, returnVal interface{}) (resp *http.Response, err error)

func NewAuthenticatedJSONRequest

func NewAuthenticatedJSONRequest(instance *config.Instance, method string, path string, payload interface{}, returnVal interface{}) (resp *http.Response, err error)

func NewAuthenticatedRequest

func NewAuthenticatedRequest(instance *config.Instance, method string, path string, body io.Reader) (req *http.Request, err error)

func PipelinesMatchingCommit

func PipelinesMatchingCommit(instance *config.Instance, projectId int64, commit string) (pipelines []int64, err error)

* PipelinesMatchingCommit returns a slice of matching pipeline IDs.

func Version

func Version() (string, error)

Types

type Issue

type Issue struct {
	ID           int64     `json:"id"`
	IID          int64     `json:"iid"`
	ProjectId    int64     `json:"project_id"`
	State        string    `json:"state"`
	Title        string    `json:"title"`
	Description  string    `json:"description"`
	Author       User      `json:"author"`
	Assignees    []User    `json:"assignees,omitempty"`
	Assignee     User      `json:"assignee,omitempty"` //Deprecated on API level
	Milestone    Milestone `json:"milestone"`
	Labels       []string  `json:"labels"`
	WebURL       string    `json:"web_url"`
	Confidential bool      `json:"confidential"`
}

func GetAssignedIssues

func GetAssignedIssues(instance *config.Instance) (issues []*Issue, err error)

* ProjectByPath returns the project of a project path/namespace.

func GetIssuesByFilter

func GetIssuesByFilter(instance *config.Instance, filter string) (issues []*Issue, err error)

type Job

type Job struct {
	ID     int64  `json:"id"`
	Name   string `json:"name"`
	Stage  string `json:"stage"`
	Status string `json:"status"`
}

func CancelJob

func CancelJob(instance *config.Instance, projectId int64, jobId int64) (job *Job, err error)

func GetJob

func GetJob(instance *config.Instance, projectId int64, jobId int64) (job Job, err error)

func JobsByPipeline

func JobsByPipeline(instance *config.Instance, projectId int64, pipelineID int64) (jobs []Job, err error)

func RetryJob

func RetryJob(instance *config.Instance, projectId int64, jobId int64) (job *Job, err error)

func TriggerJob

func TriggerJob(instance *config.Instance, projectId int64, jobId int64, endpoint string) (job *Job, err error)

func TriggerManualJob

func TriggerManualJob(instance *config.Instance, projectId int64, jobId int64) (job *Job, err error)

type MergeRequest

type MergeRequest struct {
	SourceBranch string `json:"source_branch"`
	TargetBranch string `json:"target_branch"`
	Title        string `json:"title"`
	Description  string `json:"description,omitempty"`
}

type MergeRequestResponse

type MergeRequestResponse struct {
	MergeRequest
	IId    int64  `json:"iid"`
	WebURL string `json:"web_url"`
}

func CreateMergeRequest

func CreateMergeRequest(instance *config.Instance, projectID int64, mr *MergeRequest) (mrr *MergeRequestResponse, err error)

type Milestone

type Milestone struct {
	ID          int64  `json:"id"`
	IID         int64  `json:"iid"`
	Description string `json:"description"`
}

type PipelineRequest

type PipelineRequest struct {
	Ref       string             `json:"ref"`
	Variables []PipelineVariable `json:"variables"`
}

type PipelineVariable

type PipelineVariable struct {
	Key          string `json:"key"`
	VariableType string `json:"variable_type"`
	Value        string `json:"value"`
}

type Project

type Project struct {
	ID                int64  `json:"id"`
	Name              string `json:"name"`
	NameWithNamespace string `json:"name_with_namespace"`
	PathWithNamespace string `json:"path_with_namespace"`
	SSHURL            string `json:"ssh_url_to_repo"`
	HTTPURL           string `json:"http_url_to_repo"`
	WebURL            string `json:"web_url"`
	Visibility        string `json:"visibility"`
	DefaultBranch     string `json:"default_branch"`
	Archived          bool   `json:"archived"`
}

func ProjectByID

func ProjectByID(instance *config.Instance, projectId int64) (project *Project, err error)

* ProjectByID returns the project of a project id.

func ProjectByPath

func ProjectByPath(instance *config.Instance, projectPath string) (project *Project, err error)

* ProjectByPath returns the project of a project path/namespace.

type Todo

type Todo struct {
	ID      int64 `json:"id"`
	Project struct {
		Id                int64  `json:"id"`
		NameWithNamespace string `json:"name_with_namespace"`
	} `json:"project"` //This is because of stupid API design
	Author     User     `json:"author"`
	ActionName string   `json:"action_name"`
	TargetType string   `json:"target_type"`
	Target     struct{} `json:"target"` //TODO
	TargetURL  string   `json:"target_url"`
	Body       string   `json:"body"`
	State      string   `json:"state"`
	CreatedAt  string   `json:"created_at"`
}

func GetTodos

func GetTodos(instance *config.Instance, inDoneState bool) (todos []*Todo, err error)

type User

type User struct {
	Id       uint   `json:"id,omitempty"`
	Name     string `json:"name,omitempty"`
	UserName string `json:"username,omitempty"`
	WebURL   string `json:"web_url,omitempty"`
}

func CurrentUser

func CurrentUser(instance *config.Instance) (project *User, err error)

* CurrentUser returns the currently logged in user.

Jump to

Keyboard shortcuts

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