gogitlab

package module
v0.0.0-...-0454652 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2017 License: MIT Imports: 13 Imported by: 0

README

go-gitlab-client

================

go-gitlab-client is a simple client written in golang to consume gitlab API.

Build Status

features

  • Projects gitlab api doc
    • list projects
    • add/get/edit/rm single project
  • Repositories gitlab api doc
    • list repository branches
    • get single repository branch
    • list project repository tags
    • list repository commits
    • list project hooks
    • add/get/edit/rm project hook
  • Users gitlab api doc
    • get single user
    • manage user keys
  • Groups gitlab api doc
    • list groups
    • add/get/edit/rm single group
    • list projects in a group
    • list members in a group
  • Deploy Keys gitlab api doc
    • list project deploy keys
    • add/get/rm project deploy key
  • Builds gitlab api doc
    • List project builds
    • Get a single build
    • List commit builds
    • Get build artifacts
    • Cancel a build
    • Retry a build
    • Erase a build
  • Runners gitlab api doc
    • list owned runners
    • list shared runners
    • list projects runners
    • get a single runner
    • update/remove runner
    • enable/disable runner in project

Installation

To install go-gitlab-client, use go get:

go get github.com/plouc/go-gitlab-client

Import the go-gitlab-client package into your code:

package whatever

import (
    "github.com/plouc/go-gitlab-client"
)

Update

To update go-gitlab-client, use go get -u:

go get -u github.com/plouc/go-gitlab-client

##Documentation

Visit the docs at http://godoc.org/github.com/plouc/go-gitlab-client

Examples

You can play with the examples located in the examples directory

Documentation

Overview

Package github implements a simple client to consume gitlab API.

Index

Constants

View Source
const (
	// VisibilityPrivate indicates project access must be granted explicitly for each user.
	VisibilityPrivate = Visibility("private")

	// VisibilityInternal indicates the project can be cloned by any logged in user.
	VisibilityInternal = Visibility("internal")

	// VisibilityPublic indicates the project can be cloned without any authentication.
	VisibilityPublic = Visibility("public")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AcceptMergeRequestRequest

type AcceptMergeRequestRequest struct {
	MergeCommitMessage       string `json:"merge_commit_message,omitempty"`
	ShouldRemoveSourceBranch bool   `json:"should_remove_source_branch,omitempty"`
	MergedWhenBuildSucceeds  bool   `json:"merged_when_build_succeeds,omitempty"`
}

type ActivityFeed

type ActivityFeed struct {
	Title   string        `xml:"title" json:"title"`
	Id      string        `xml:"id" json:"id"`
	Link    []Link        `xml:"link" json:"link"`
	Updated time.Time     `xml:"updated,attr" json:"updated"`
	Entries []*FeedCommit `xml:"entry" json:"entries"`
}

type AddMergeRequestRequest

type AddMergeRequestRequest struct {
	SourceBranch    string   `json:"source_branch"`
	TargetBranch    string   `json:"target_branch"`
	AssigneeId      int      `json:"assignee_id,omitempty"`
	Title           string   `json:"title"`
	Description     string   `json:"description,omitempty"`
	TargetProjectId int      `json:"target_project_id,omitempty"`
	Lables          []string `json:"lables,omitempty"`
}

type ArtifactsFile

type ArtifactsFile struct {
	Filename string `json:"filename"`
	Size     int    `json:"size"`
}

type Branch

type Branch struct {
	Name      string        `json:"name,omitempty"`
	Protected bool          `json:"protected,omitempty"`
	Commit    *BranchCommit `json:"commit,omitempty"`
}

type BranchCommit

type BranchCommit struct {
	Id               string  `json:"id,omitempty"`
	Tree             string  `json:"tree,omitempty"`
	AuthoredDateRaw  string  `json:"authored_date,omitempty"`
	CommittedDateRaw string  `json:"committed_date,omitempty"`
	Message          string  `json:"message,omitempty"`
	Author           *Person `json:"author,omitempty"`
	Committer        *Person `json:"committer,omitempty"`
}

type Build

type Build struct {
	Id            int           `json:"id"`
	ArtifactsFile ArtifactsFile `json:"artifacts_file"`
	Commit        Commit        `json:"commit,omitempty"`
	CreatedAt     string        `json:"created_at"`
	DownloadURL   string        `json:"download_url"`
	FinishedAt    string        `json:"finished_at"`
	Name          string        `json:"name"`
	Ref           string        `json:"ref"`
	Stage         string        `json:"stage"`
	StartedAt     string        `json:"started_at"`
	Status        string        `json:"status"`
	Tag           bool          `json:"tag"`
	User          User          `json:"user"`
	When          string        `json:"when,omitempty"`
	Manual        bool          `json:"manual,omitempty"`
}

type ChangeItem

type ChangeItem struct {
	OldPath     string `json:"old_path,omitempty"`
	NewPath     string `json:"new_path,omitempty"`
	AMode       string `json:"a_mode,omitempty"`
	BMode       string `json:"b_mode,omitempty"`
	Diff        string `json:"diff,omitempty"`
	NewFile     bool   `json:"new_file,omitempty"`
	RenamedFile bool   `json:"renamed_file,omitempty"`
	DeletedFile bool   `json:"deleted_file,omitempty"`
}

type Commit

type Commit struct {
	Id           string
	Short_Id     string
	Title        string
	Author_Name  string
	Author_Email string
	Created_At   string
	CreatedAt    time.Time
	Message      string
}

type CommitStatus

type CommitStatus struct {
	Status       string     `json:"status"`
	CreatedAt    time.Time  `json:"created_at"`
	StartedAt    *time.Time `json:"started_at"`
	Name         string     `json:"name"`
	AllowFailure bool       `json:"allow_failure"`
	Author       User       `json:"author"`
	Description  *string    `json:"description"`
	Sha          string     `json:"sha"`
	TargetURL    string     `json:"target_url"`
	FinishedAt   *time.Time `json:"finished_at"`
	ID           int        `json:"id"`
	Ref          string     `json:"ref"`
}

type FeedCommit

type FeedCommit struct {
	Id      string    `xml:"id" json:"id"`
	Title   string    `xml:"title" json:"title"`
	Link    []Link    `xml:"link" json:"link"`
	Updated time.Time `xml:"updated" json:"updated"`
	Author  Person    `xml:"author" json:"author"`
	Summary string    `xml:"summary" json:"summary"`
}

type Gitlab

type Gitlab struct {
	BaseUrl      string
	ApiPath      string
	RepoFeedPath string
	Token        string
	Client       *http.Client
}

func NewGitlab

func NewGitlab(baseUrl, apiPath, token string) *Gitlab

func (*Gitlab) Activity

func (g *Gitlab) Activity() (ActivityFeed, error)

func (*Gitlab) AddGroup

func (g *Gitlab) AddGroup(group *Group) (*Group, error)

Creates a new project group. Available only for users who can create groups.

Required fields on group:

  • Name
  • Path

Optional fields on group:

  • Description
  • Visibility
  • LfsEnabled
  • RequestAccessEnabled
  • ParentId

Other fields on group are not supported by the GitLab API

func (*Gitlab) AddIssue

func (g *Gitlab) AddIssue(projectId string, req *IssueRequest) (issue *Issue, err error)

func (*Gitlab) AddKey

func (g *Gitlab) AddKey(title, key string) error

func (*Gitlab) AddMergeRequest

func (g *Gitlab) AddMergeRequest(req *AddMergeRequestRequest) (*MergeRequest, error)

Creates a new merge request.

POST /projects/:id/merge_requests

Parameters:

id               The ID of a project

func (*Gitlab) AddProject

func (g *Gitlab) AddProject(project *Project) (*Project, error)

Creates a new project owned by the authenticated user.

One (or more) of the following fields are required:

  • Name
  • Path

func (*Gitlab) AddProjectDeployKey

func (g *Gitlab) AddProjectDeployKey(id, title, key string) error

Add deploy key to project.

POST /projects/:id/keys

Parameters:

id    The ID of a project
title The key title
key   The key value

func (*Gitlab) AddProjectHook

func (g *Gitlab) AddProjectHook(id, hook_url string, push_events, issues_events, merge_requests_events bool) error

Add new project hook.

POST /projects/:id/hooks

Parameters:

id                    The ID or NAMESPACE/PROJECT_NAME of a project
hook_url              The hook URL
push_events           Trigger hook on push events
issues_events         Trigger hook on issues events
merge_requests_events Trigger hook on merge_requests events

func (*Gitlab) AddUserKey

func (g *Gitlab) AddUserKey(id, title, key string) error

func (*Gitlab) AllProjects

func (g *Gitlab) AllProjects() ([]*Project, error)

Get a list of all GitLab projects (admin only).

func (*Gitlab) AllRunners

func (g *Gitlab) AllRunners(page, per_page int) ([]*Runner, error)

Get all runners.

GET /runners/all

Parameters:

page The start page
per_page Number of runners per page

Usage:

runners, err := gitlab.AllRunners(0,20)
if err != nil {
  fmt.Println(err.Error())
}
fmt.Printf("%+v\n", runner)

func (*Gitlab) CurrentUser

func (g *Gitlab) CurrentUser() (User, error)

func (*Gitlab) DeleteKey

func (g *Gitlab) DeleteKey(id string) error

func (*Gitlab) DeleteRunner

func (g *Gitlab) DeleteRunner(id int) (*Runner, error)

Delete a runner.

DELETE /runners/:id

Parameters:

id The id of a runner.

Usage:

runner, err := gitlab.DeleteRunner(6)
if err != nil {
  fmt.Println(err.Error())
}

func (*Gitlab) DeleteUser

func (g *Gitlab) DeleteUser(id string) error

func (*Gitlab) DisableProjectRunner

func (g *Gitlab) DisableProjectRunner(project_id string, id int) (*Runner, error)

Disable a specific Project Runner

func (*Gitlab) EditMergeRequest

func (g *Gitlab) EditMergeRequest(mr *MergeRequest) error

Updates an existing merge request.

PUT /projects/:id/merge_request/:merge_request_id

Parameters:

id               The ID of a project

func (*Gitlab) EditProjectHook

func (g *Gitlab) EditProjectHook(id, hook_id, hook_url string, push_events, issues_events, merge_requests_events bool) error

Edit existing project hook.

PUT /projects/:id/hooks/:hook_id

Parameters:

id                    The ID or NAMESPACE/PROJECT_NAME of a project
hook_id               The ID of a project hook
hook_url              The hook URL
push_events           Trigger hook on push events
issues_events         Trigger hook on issues events
merge_requests_events Trigger hook on merge_requests events

func (*Gitlab) EnableProjectRunner

func (g *Gitlab) EnableProjectRunner(project_id string, id int) (*Runner, error)

Enable a specific Project Runner

func (*Gitlab) Group

func (g *Gitlab) Group(id string) (*Group, error)

Get all details of a group

func (*Gitlab) GroupMembers

func (g *Gitlab) GroupMembers(id string) ([]*Member, error)

Gets a list of group or project members viewable by the authenticated user

func (*Gitlab) GroupProjects

func (g *Gitlab) GroupProjects(id string) ([]*Project, error)

Get a list of projects in this group.

func (*Gitlab) Groups

func (g *Gitlab) Groups() ([]*Group, error)

Get a list of groups. (As user: my groups or all available, as admin: all groups)

func (*Gitlab) ListKeys

func (g *Gitlab) ListKeys(id string) ([]*PublicKey, error)

func (*Gitlab) Namespaces

func (g *Gitlab) Namespaces() ([]*nNamespace, error)

func (*Gitlab) Project

func (g *Gitlab) Project(id string) (*Project, error)

Get a specific project, identified by project ID or NAME, which is owned by the authentication user. Namespaced project may be retrieved by specifying the namespace and its project name like this:

`namespace%2Fproject-name`

func (*Gitlab) ProjectBranches

func (g *Gitlab) ProjectBranches(id string) ([]*Branch, error)

Lists all branches of a project.

func (*Gitlab) ProjectBuild

func (g *Gitlab) ProjectBuild(id, buildId string) (*Build, error)

func (*Gitlab) ProjectBuildArtifacts

func (g *Gitlab) ProjectBuildArtifacts(id, buildId string) (io.ReadCloser, error)

func (*Gitlab) ProjectBuilds

func (g *Gitlab) ProjectBuilds(id string) ([]*Build, error)

func (*Gitlab) ProjectCancelBuild

func (g *Gitlab) ProjectCancelBuild(id, buildId string) (*Build, error)

func (*Gitlab) ProjectCommitBuilds

func (g *Gitlab) ProjectCommitBuilds(id, sha1 string) ([]*Build, error)

func (*Gitlab) ProjectCommitStatuses

func (g *Gitlab) ProjectCommitStatuses(id, sha1 string) ([]*CommitStatus, error)

func (*Gitlab) ProjectDeployKey

func (g *Gitlab) ProjectDeployKey(id, key_id string) (*PublicKey, error)

Get single project deploy key.

GET /projects/:id/keys/:key_id

Parameters:

id     The ID of a project
key_id The ID of a key

func (*Gitlab) ProjectDeployKeys

func (g *Gitlab) ProjectDeployKeys(id string) ([]*PublicKey, error)

Get list of project deploy keys.

GET /projects/:id/keys

Parameters:

id The ID of a project

func (*Gitlab) ProjectEraseBuild

func (g *Gitlab) ProjectEraseBuild(id, buildId string) (*Build, error)

func (*Gitlab) ProjectHook

func (g *Gitlab) ProjectHook(id, hook_id string) (*Hook, error)

Get single project hook.

GET /projects/:id/hooks/:hook_id

Parameters:

id      The ID of a project
hook_id The ID of a hook

func (*Gitlab) ProjectHooks

func (g *Gitlab) ProjectHooks(id string) ([]*Hook, error)

Get list of project hooks.

GET /projects/:id/hooks

Parameters:

id The ID of a project

func (*Gitlab) ProjectMembers

func (g *Gitlab) ProjectMembers(id string) ([]*Member, error)

func (*Gitlab) ProjectMergeRequest

func (g *Gitlab) ProjectMergeRequest(id, merge_request_id string) (*MergeRequest, error)

Get single project merge request.

GET /projects/:id/merge_requests/:merge_request_id

Parameters:

id               The ID of a project
merge_request_id The ID of a merge request

func (*Gitlab) ProjectMergeRequestAccept

func (g *Gitlab) ProjectMergeRequestAccept(id, merge_request_id string, req *AcceptMergeRequestRequest) (*MergeRequest, error)

Merge changes submitted with MR.

PUT /projects/:id/merge_request/:merge_request_id/merge

Parameters:

id               The ID of a project
merge_request_id The ID of a merge request

func (*Gitlab) ProjectMergeRequestCancelMerge

func (g *Gitlab) ProjectMergeRequestCancelMerge(id, merge_request_id string) (*MergeRequest, error)

Cancel Merge When Build Succeeds.

PUT /projects/:id/merge_request/:merge_request_id/cancel_merge_when_build_succeeds

Parameters:

id               The ID of a project
merge_request_id The ID of a merge request

func (*Gitlab) ProjectMergeRequestChanges

func (g *Gitlab) ProjectMergeRequestChanges(id, merge_request_id string) (*MergeRequestChanges, error)

Get information about the merge request including its files and changes.

GET /projects/:id/merge_request/:merge_request_id/changes

Parameters:

id               The ID of a project
merge_request_id The ID of a merge request

func (*Gitlab) ProjectMergeRequestCommits

func (g *Gitlab) ProjectMergeRequestCommits(id, merge_request_id string) ([]*Commit, error)

Get a list of merge request commits.

GET /projects/:id/merge_request/:merge_request_id/commits

Parameters:

id               The ID of a project
merge_request_id The ID of a merge request

func (*Gitlab) ProjectMergeRequests

func (g *Gitlab) ProjectMergeRequests(id string, params map[string]string) ([]*MergeRequest, error)

Get list of project merge requests.

GET /projects/:id/merge_requests

Parameters:

id The ID of a project

Params:

iid (optional) - Return the request having the given iid
state (optional) - Return all requests or just those that are merged, opened or closed
order_by (optional) - Return requests ordered by created_at or updated_at fields. Default is created_at
sort (optional) - Return requests sorted in asc or desc order. Default is desc

func (*Gitlab) ProjectRetryBuild

func (g *Gitlab) ProjectRetryBuild(id, buildId string) (*Build, error)

func (*Gitlab) ProjectRunners

func (g *Gitlab) ProjectRunners(project_id string, page, per_page int) ([]*Runner, error)

Get all projects runners.

GET /projects/:id/runners

Parameters:

page The start page
per_page Number of runners per page

Usage:

runners, err := gitlab.AllRunners(0,20)
if err != nil {
  fmt.Println(err.Error())
}
fmt.Printf("%+v\n", runner)

func (*Gitlab) Projects

func (g *Gitlab) Projects() ([]*Project, error)

Get a list of projects owned by the authenticated user.

func (*Gitlab) RemoveGroup

func (g *Gitlab) RemoveGroup(id string) (bool, error)

Remove a group.

func (*Gitlab) RemoveProject

func (g *Gitlab) RemoveProject(id string) (bool, error)

Remove a project.

func (*Gitlab) RemoveProjectDeployKey

func (g *Gitlab) RemoveProjectDeployKey(id, key_id string) error

Remove deploy key from project

DELETE /projects/:id/keys/:key_id

Parameters:

id     The ID of a project
key_id The ID of a key

func (*Gitlab) RemoveProjectHook

func (g *Gitlab) RemoveProjectHook(id, hook_id string) error

Remove hook from project.

DELETE /projects/:id/hooks/:hook_id

Parameters:

id      The ID or NAMESPACE/PROJECT_NAME of a project
hook_id The ID of hook to delete

func (*Gitlab) RepoActivityFeed

func (g *Gitlab) RepoActivityFeed(feedPath string) ActivityFeed

func (*Gitlab) RepoBranch

func (g *Gitlab) RepoBranch(id, refName string) (*Branch, error)

Get a single project repository branch.

GET /projects/:id/repository/branches/:branch

Parameters:

id     The ID of a project
branch The name of the branch

func (*Gitlab) RepoBranches

func (g *Gitlab) RepoBranches(id string) ([]*Branch, error)

Get a list of repository branches from a project, sorted by name alphabetically.

GET /projects/:id/repository/branches

Parameters:

id The ID of a project

Usage:

branches, err := gitlab.RepoBranches("your_projet_id")
if err != nil {
	fmt.Println(err.Error())
}
for _, branch := range branches {
	fmt.Printf("%+v\n", branch)
}

func (*Gitlab) RepoCommits

func (g *Gitlab) RepoCommits(id string) ([]*Commit, error)

Get a list of repository commits in a project.

GET /projects/:id/repository/commits

Parameters:

    id      The ID of a project
	refName The name of a repository branch or tag or if not given the default branch

Usage:

commits, err := gitlab.RepoCommits("your_projet_id")
if err != nil {
	fmt.Println(err.Error())
}
for _, commit := range commits {
	fmt.Printf("%+v\n", commit)
}

func (*Gitlab) RepoRawFile

func (g *Gitlab) RepoRawFile(id, sha, filepath string) ([]byte, error)

Get Raw file content

func (*Gitlab) RepoTags

func (g *Gitlab) RepoTags(id string) ([]*Tag, error)

Get a list of repository tags from a project, sorted by name in reverse alphabetical order.

GET /projects/:id/repository/tags

Parameters:

id The ID of a project

Usage:

tags, err := gitlab.RepoTags("your_projet_id")
if err != nil {
	fmt.Println(err.Error())
}
for _, tag := range tags {
	fmt.Printf("%+v\n", tag)
}

func (*Gitlab) RepoTree

func (g *Gitlab) RepoTree(id, path, ref_name string) ([]*TreeNode, error)

Get a list of repository files and directories in a project.

GET /projects/:id/repository/tree

Parameters:

    id (required) The ID of a project
    path (optional) The path inside repository. Used to get contend of subdirectories
		ref_name (optional) The name of a repository branch or tag or if not given the default branch

Usage:

pass nil when not using optional parameters

func (*Gitlab) ResourceUrl

func (g *Gitlab) ResourceUrl(url string, params map[string]string) string

func (*Gitlab) ResourceUrlRaw

func (g *Gitlab) ResourceUrlRaw(u string, params map[string]string) (string, string)

func (*Gitlab) Runner

func (g *Gitlab) Runner(id int) (*Runner, error)

Get a single runner.

GET /runners/:id

Parameters:

id The ID of a runner

Usage:

runner, err := gitlab.Runner(your_runner_id)
if err != nil {
  fmt.Println(err.Error())
}
fmt.Printf("%+v\n", runner)

func (*Gitlab) Runners

func (g *Gitlab) Runners(page, per_page int) ([]*Runner, error)

Get all runners owned by the authenticated user.

GET /runners/:id

Parameters:

id The ID of a runner

Usage:

runner, err := gitlab.Runner(your_runner_id)
if err != nil {
  fmt.Println(err.Error())
}
fmt.Printf("%+v\n", runner)

func (*Gitlab) SearchNamespaces

func (g *Gitlab) SearchNamespaces(query string) ([]*nNamespace, error)

func (*Gitlab) UpdateGroup

func (g *Gitlab) UpdateGroup(id string, group *Group) (*Group, error)

Updates the project group. Only available to group owners and administrators.

func (*Gitlab) UpdateProject

func (g *Gitlab) UpdateProject(id string, project *Project) (*Project, error)

Update a specific project, identified by project ID or NAME, which is owned by the authentication user. Namespaced project may be retrieved by specifying the namespace and its project name like this:

`namespace%2Fproject-name`

func (*Gitlab) UpdateRunner

func (g *Gitlab) UpdateRunner(id int, runner *Runner) (*Runner, error)

Update a specific runner, identified by runner ID, which is owned by the authentication user.

func (*Gitlab) User

func (g *Gitlab) User(id string) (*User, error)

Get a single user.

GET /users/:id

Parameters:

id The ID of a user

Usage:

user, err := gitlab.User("your_user_id")
if err != nil {
	fmt.Println(err.Error())
}
fmt.Printf("%+v\n", user)

func (*Gitlab) UserKey

func (g *Gitlab) UserKey(id string) (*PublicKey, error)

func (*Gitlab) UserKeys

func (g *Gitlab) UserKeys() ([]*PublicKey, error)

func (*Gitlab) Users

func (g *Gitlab) Users(page, per_page int) ([]*User, error)

type Group

type Group struct {
	Id                        int        `json:"id,omitempty"`
	Name                      string     `json:"name,omitempty"`
	Path                      string     `json:"path,omitempty"`
	Description               string     `json:"description,omitempty"`
	Visibility                Visibility `json:"visibility,omitempty"`
	LfsEnabled                bool       `json:"lfs_enabled,omitempty"`
	AvatarUrl                 string     `json:"avatar_url,omitempty"`
	WebURL                    string     `json:"web_url,omitempty"`
	RequestAccessEnabled      bool       `json:"request_access_enabled,omitempty"`
	FullName                  string     `json:"full_name,omitempty"`
	FullPath                  string     `json:"full_path,omitempty"`
	ParentId                  int        `json:"parent_id,omitempty"`
	SharedRunnersMinutesLimit int        `json:"shared_runners_minutes_limit,omitempty"`
	Projects                  []*Project `json:"projects,omitempty"`
}

A gitlab group

type Hook

type Hook struct {
	Id           int    `json:"id,omitempty"`
	Url          string `json:"url,omitempty"`
	CreatedAtRaw string `json:"created_at,omitempty"`
}

type HookObjAttr

type HookObjAttr struct {
	Id              int       `json:"id,omitempty"`
	Ref             string    `json:"ref,omitempty"`
	Tag             bool      `json:"tag,omitempty"`
	Sha             string    `json:"sha,omitempty"`
	BeforeSha       string    `json:"before_sha,omitempty"`
	Title           string    `json:"title,omitempty"`
	AssigneeId      int       `json:"assignee_id,omitempty"`
	AuthorId        int       `json:"author_id,omitempty"`
	ProjectId       int       `json:"project_id,omitempty"`
	Status          string    `json:"status,omitempty"`
	Stages          []string  `json:"stages,omitempty"`
	CreatedAt       time.Time `json:"created_at,omitempty"`
	UpdatedAt       time.Time `json:"updated_at,omitempty"`
	FinishedAt      time.Time `json:"finished_at,omitempty"`
	Duration        int       `json:"duration,omitempty"`
	Position        int       `json:"position,omitempty"`
	BranchName      string    `json:"branch_name,omitempty"`
	Description     string    `json:"description,omitempty"`
	MilestoneId     int       `json:"milestone_id,omitempty"`
	State           string    `json:"state,omitempty"`
	IId             int       `json:"iid,omitempty"`
	TargetBranch    string    `json:"target_branch,omitempty"`
	SourceBranch    string    `json:"source_branch,omitempty"`
	SourceProjectId int       `json:"source_project_id,omitempty"`
	StCommits       string    `json:"st_commits,omitempty"`
	StDiffs         string    `json:"st_diffs,omitempty"`
	MergeStatus     string    `json:"merge_status,omitempty"`
	TargetProjectId int       `json:"target_project_id,omitempty"`
}

type HookPayload

type HookPayload struct {
	Before            string       `json:"before,omitempty"`
	After             string       `json:"after,omitempty"`
	Ref               string       `json:"ref,omitempty"`
	UserId            int          `json:"user_id,omitempty"`
	UserName          string       `json:"user_name,omitempty"`
	ProjectId         int          `json:"project_id,omitempty"`
	Project           *hProject    `json:"project,omitempty"`
	Repository        *hRepository `json:"repository,omitempty"`
	Commits           []hCommit    `json:"commits,omitempty"`
	Commit            *hCommit     `json:"commit,omitempty"`
	TotalCommitsCount int          `json:"total_commits_count,omitempty"`
	ObjectKind        string       `json:"object_kind,omitempty"`
	ObjectAttributes  *HookObjAttr `json:"object_attributes,omitempty"`
	Builds            []*Build     `json:"builds,omitempty"`
}

func ParseHook

func ParseHook(payload []byte) (*HookPayload, error)

ParseHook parses hook payload from GitLab

func (*HookPayload) Branch

func (h *HookPayload) Branch() string

Branch returns current branch for pipeline and push event hook payload This function returns empty string for any other events

func (*HookPayload) Head

func (h *HookPayload) Head() hCommit

Head returns the latest changeset for push event hook payload

type Issue

type Issue struct {
	Id          int        `json:"id"`
	IId         int        `json:"iid"`
	ProjectId   int        `json:"project_id,omitempty"`
	Title       string     `json:"title,omitempty"`
	Description string     `json:"description,omitempty"`
	Labels      []string   `json:"labels,omitempty"`
	Milestone   *Milestone `json:"milestone,omitempty"`
	Assignee    *User      `json:"assignee,omitempty"`
	Author      *User      `json:"author,omitempty"`
	State       string     `json:"state,omitempty"`
	CreatedAt   string     `json:"created_at,omitempty"`
	UpdatedAt   string     `json:"updated_at,omitempty"`
}

type IssueRequest

type IssueRequest struct {
	Title       string `json:"title"`
	Description string `json:"description,omitempty"`
	AssigneeId  int    `json:"assignee_id,omitempty"`
	MilestoneId int    `json:"milestone_id,omitempty"`
	Labels      string `json:"labels,omitempty"`
}
type Link struct {
	Rel  string `xml:"rel,attr,omitempty" json:"rel"`
	Href string `xml:"href,attr" json:"href"`
}

type Member

type Member struct {
	Id        int
	Username  string
	Email     string
	Name      string
	State     string
	CreatedAt string `json:"created_at,omitempty"`
}

type MergeRequest

type MergeRequest struct {
	Id              int    `json:"id,omitempty"`
	Iid             int    `json:"iid,omitempty"`
	TargetBranch    string `json:"target_branch,omitempty"`
	SourceBranch    string `json:"source_branch,omitempty"`
	ProjectId       int    `json:"project_id,omitempty"`
	Title           string `json:"title,omitempty"`
	State           string `json:"state,omitempty"`
	CreatedAt       string `json:"created_at,omitempty"`
	UpdatedAt       string `json:"updated_at,omitempty"`
	Upvotes         int    `json:"upvotes,omitempty"`
	Downvotes       int    `json:"downvotes,omitempty"`
	Author          *User  `json:"author,omitempty"`
	Assignee        *User  `json:"assignee,omitempty"`
	Description     string `json:"description,omitempty"`
	WorkInProgress  bool   `json:"work_in_progress,omitempty"`
	MergeStatus     string `json:"merge_status,omitempty"`
	SourceProjectID int    `json:"source_project_id,omitempty"`
	TargetProjectID int    `json:"target_project_id,omitempty"`
}

type MergeRequestChanges

type MergeRequestChanges struct {
	*MergeRequest
	CreatedAt       string       `json:"created_at,omitempty"`
	UpdatedAt       string       `json:"updated_at,omitempty"`
	SourceProjectId int          `json:"source_project_id,omitempty"`
	TargetProjectId int          `json:"target_project_id,omitempty"`
	Labels          []string     `json:"labels,omitempty"`
	Milestone       Milestone    `json:"milestone,omitempty"`
	Changes         []ChangeItem `json:"changes,omitempty"`
}

type Milestone

type Milestone struct {
	Id          int    `json:"id,omitempty"`
	IId         int    `json:"iid,omitempty"`
	ProjectId   int    `json:"project_id,omitempty"`
	Title       string `json:"title,omitempty"`
	Description string `json:"description,omitempty"`
	DueDate     string `json:"due_date,omitempty"`
	State       string `json:"state,omitempty"`
	CreatedAt   string `json:"created_at"`
	UpdatedAt   string `json:"updated_at,omitempty"`
}

type Namespace

type Namespace struct {
	Id          int
	Name        string
	Path        string
	Description string
	Owner_Id    int
	Created_At  string
	Updated_At  string
}

type Person

type Person struct {
	Name  string `xml:"name" json:"name"`
	Email string `xml:"email" json:"email"`
}

type Project

type Project struct {
	Id                   int        `json:"id,omitempty"`
	Name                 string     `json:"name,omitempty"`
	Description          string     `json:"description,omitempty"`
	DefaultBranch        string     `json:"default_branch,omitempty"`
	Owner                *Member    `json:"owner,omitempty"`
	Public               bool       `json:"public,omitempty"`
	Path                 string     `json:"path,omitempty"`
	PathWithNamespace    string     `json:"path_with_namespace,omitempty"`
	Visibility           Visibility `json:"visibility,omitempty"`
	IssuesEnabled        bool       `json:"issues_enabled,omitempty"`
	MergeRequestsEnabled bool       `json:"merge_requests_enabled,omitempty"`
	WallEnabled          bool       `json:"wall_enabled,omitempty"`
	WikiEnabled          bool       `json:"wiki_enabled,omitempty"`
	CreatedAtRaw         string     `json:"created_at,omitempty"`
	Namespace            *Namespace `json:"namespace,omitempty"`
	NamespaceId          int        `json:"namespace_id,omitempty"` // Only used for create
	SshRepoUrl           string     `json:"ssh_url_to_repo"`
	HttpRepoUrl          string     `json:"http_url_to_repo"`
	WebUrl               string     `json:"web_url"`
	SharedRunners        bool       `json:"shared_runners_enabled"`
}

A gitlab project

type PublicKey

type PublicKey struct {
	Id           int    `json:"id,omitempty"`
	Title        string `json:"title,omitempty"`
	Key          string `json:"key,omitempty"`
	CreatedAtRaw string `json:"created_at,omitempty"`
}

type Runner

type Runner struct {
	Id           int        `json:"id,omitempty"`
	Name         string     `json:"name,omitempty"`
	Description  string     `json:"description,omitempty"`
	Token        string     `json:"token,omitempty"`
	Revision     string     `json:"revision,omitempty"`
	ContactedAt  string     `json:"contacted_at,omitempty"`
	Platform     string     `json:"platform,omitempty"`
	Version      string     `json:"version,omitempty"`
	Architecture string     `json:"architecture,omitempty"`
	Projects     []*Project `json:"projects,omitempty"`
	TagList      []string   `json:"tag_list,omitempty"`
	Active       bool       `json:"active,omitempty"`
	IsShared     bool       `json:"is_shared,omitempty"`
}

type Tag

type Tag struct {
	Name      string        `json:"name,omitempty"`
	Protected bool          `json:"protected,omitempty"`
	Commit    *BranchCommit `json:"commit,omitempty"`
}

type TreeNode

type TreeNode struct {
	Name string
	Type string
	Mode string
	Id   string
}

type User

type User struct {
	Id            int    `json:"id,omitempty"`
	Username      string `json:"username,omitempty"`
	Email         string `json:"email,omitempty"`
	Name          string `json:"name,omitempty"`
	State         string `json:"state,omitempty"`
	CreatedAt     string `json:"created_at,omitempty"`
	Bio           string `json:"bio,omitempty"`
	Skype         string `json:"skype,omitempty"`
	LinkedIn      string `json:"linkedin,omitempty"`
	Twitter       string `json:"twitter,omitempty"`
	WebURL        string `json:"web_url"`
	ExternUid     string `json:"extern_uid,omitempty"`
	Provider      string `json:"provider,omitempty"`
	ThemeId       int    `json:"theme_id,omitempty"`
	ColorSchemeId int    `json:"color_scheme_id,omitempty"`
	AvatarUrl     string `json:"avatar_url,omitempty"`
}

type Visibility

type Visibility string

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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