1
0
Fork 0
forked from forgejo/forgejo

Vendor Update (#14496)

* update code.gitea.io/sdk/gitea v0.13.1 -> v0.13.2

* update github.com/go-swagger/go-swagger v0.25.0 -> v0.26.0

* update github.com/google/uuid v1.1.2 -> v1.2.0

* update github.com/klauspost/compress v1.11.3 -> v1.11.7

* update github.com/lib/pq 083382b7e6fc -> v1.9.0

* update github.com/markbates/goth v1.65.0 -> v1.66.1

* update github.com/mattn/go-sqlite3 v1.14.4 -> v1.14.6

* update github.com/mgechev/revive 246eac737dc7 -> v1.0.3

* update github.com/minio/minio-go/v7 v7.0.6 -> v7.0.7

* update github.com/niklasfasching/go-org v1.3.2 -> v1.4.0

* update github.com/olivere/elastic/v7 v7.0.21 -> v7.0.22

* update github.com/pquerna/otp v1.2.0 -> v1.3.0

* update github.com/xanzy/go-gitlab v0.39.0 -> v0.42.0

* update github.com/yuin/goldmark v1.2.1 -> v1.3.1
This commit is contained in:
6543 2021-01-28 17:56:38 +01:00 committed by GitHub
parent e45bf12a34
commit d1353e1f7c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
403 changed files with 29737 additions and 14357 deletions

59
vendor/github.com/xanzy/go-gitlab/.golangci.yml generated vendored Normal file
View file

@ -0,0 +1,59 @@
# This file contains all available configuration options
# with their default values.
# Options for analysis running
run:
concurrency: 4
timeout: 10m
issues-exit-code: 1
# Include test files or not, default is true
tests: true
# Output configuration options
output:
format: line-number
# All available settings of specific linters
linters-settings:
misspell:
locale: US
ignore-words:
- noteable
unused:
# Treat code as a program (not a library) and report unused exported identifiers
check-exported: false
linters:
enable:
- asciicheck
- deadcode
- dogsled
- errorlint
- exportloopref
- goconst
- golint
- gosimple
- govet
- ineffassign
- megacheck
- misspell
- nakedret
- nolintlint
- staticcheck
- structcheck
- typecheck
- unconvert
- unused
- varcheck
- whitespace
disable:
- errcheck
disable-all: false
fast: false
issues:
# Maximum issues count per one linter (set to 0 to disable)
max-issues-per-linter: 0
# Maximum count of issues with the same text (set to 0 to disable)
max-same-issues: 0

View file

@ -1,27 +1,21 @@
language: go
arch:
- amd64
- ppc64le
- amd64
- ppc64le
go:
- 1.13.x
- 1.14.x
- 1.x
- master
stages:
- lint
- test
before_install:
- curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/v1.35.0/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.35.0
jobs:
include:
- stage: lint
script:
- go get golang.org/x/lint/golint
- golint -set_exit_status
- go vet -v
- stage: test
script:
- go test -v
script:
- golangci-lint run
- go test -v
matrix:
allow_failures:

View file

@ -26,6 +26,7 @@ type ApplicationsService struct {
client *Client
}
// Application represents a GitLab application
type Application struct {
ID int `json:"id"`
ApplicationID string `json:"application_id"`
@ -64,6 +65,8 @@ func (s *ApplicationsService) CreateApplication(opt *CreateApplicationOptions, o
return a, resp, err
}
// ListApplicationsOptions represents the available
// ListApplications() options.
type ListApplicationsOptions ListOptions
// ListApplications get a list of administrables applications by the authenticated user

View file

@ -389,17 +389,18 @@ type GetCommitStatusesOptions struct {
//
// GitLab API docs: https://docs.gitlab.com/ce/api/commits.html#get-the-status-of-a-commit
type CommitStatus struct {
ID int `json:"id"`
SHA string `json:"sha"`
Ref string `json:"ref"`
Status string `json:"status"`
Name string `json:"name"`
TargetURL string `json:"target_url"`
Description string `json:"description"`
CreatedAt *time.Time `json:"created_at"`
StartedAt *time.Time `json:"started_at"`
FinishedAt *time.Time `json:"finished_at"`
Author Author `json:"author"`
ID int `json:"id"`
SHA string `json:"sha"`
Ref string `json:"ref"`
Status string `json:"status"`
CreatedAt *time.Time `json:"created_at"`
StartedAt *time.Time `json:"started_at"`
FinishedAt *time.Time `json:"finished_at"`
Name string `json:"name"`
AllowFailure bool `json:"allow_failure"`
Author Author `json:"author"`
Description string `json:"description"`
TargetURL string `json:"target_url"`
}
// GetCommitStatuses gets the statuses of a commit in a project.

View file

@ -34,6 +34,7 @@ type Deployment struct {
IID int `json:"iid"`
Ref string `json:"ref"`
SHA string `json:"sha"`
Status string `json:"status"`
CreatedAt *time.Time `json:"created_at"`
UpdatedAt *time.Time `json:"updated_at"`
User *ProjectUser `json:"user"`
@ -53,10 +54,12 @@ type Deployment struct {
User *User `json:"user"`
Commit *Commit `json:"commit"`
Pipeline struct {
ID int `json:"id"`
SHA string `json:"sha"`
Ref string `json:"ref"`
Status string `json:"status"`
ID int `json:"id"`
SHA string `json:"sha"`
Ref string `json:"ref"`
Status string `json:"status"`
CreatedAt *time.Time `json:"created_at"`
UpdatedAt *time.Time `json:"updated_at"`
} `json:"pipeline"`
Runner *Runner `json:"runner"`
} `json:"deployable"`

View file

@ -12,6 +12,7 @@ type EventType string
// List of available event types.
const (
EventTypeBuild EventType = "Build Hook"
EventTypeDeployment EventType = "Deployment Hook"
EventTypeIssue EventType = "Issue Hook"
EventConfidentialIssue EventType = "Confidential Issue Hook"
EventTypeJob EventType = "Job Hook"
@ -140,7 +141,7 @@ func ParseSystemhook(payload []byte) (event interface{}, err error) {
event = &UserTeamSystemEvent{}
default:
switch e.ObjectKind {
case "merge_request":
case string(MergeRequestEventTargetType):
event = &MergeEvent{}
default:
return nil, fmt.Errorf("unexpected system hook type %s", e.EventName)
@ -183,6 +184,8 @@ func ParseWebhook(eventType EventType, payload []byte) (event interface{}, err e
switch eventType {
case EventTypeBuild:
event = &BuildEvent{}
case EventTypeDeployment:
event = &DeploymentEvent{}
case EventTypeIssue, EventConfidentialIssue:
event = &IssueEvent{}
case EventTypeJob:
@ -204,7 +207,7 @@ func ParseWebhook(eventType EventType, payload []byte) (event interface{}, err e
return nil, err
}
if note.ObjectKind != "note" {
if note.ObjectKind != string(NoteEventTargetType) {
return nil, fmt.Errorf("unexpected object kind %s", note.ObjectKind)
}

View file

@ -175,10 +175,18 @@ type IssueEvent struct {
} `json:"assignees"`
Labels []Label `json:"labels"`
Changes struct {
Description struct {
Previous string `json:"previous"`
Current string `json:"current"`
} `json:"description"`
Labels struct {
Previous []Label `json:"previous"`
Current []Label `json:"current"`
} `json:"labels"`
Title struct {
Previous string `json:"previous"`
Current string `json:"current"`
} `json:"title"`
UpdatedByID struct {
Previous int `json:"previous"`
Current int `json:"current"`
@ -192,23 +200,24 @@ type IssueEvent struct {
// TODO: link to docs instead of src once they are published.
// https://gitlab.com/gitlab-org/gitlab-ce/blob/master/lib/gitlab/data_builder/build.rb
type JobEvent struct {
ObjectKind string `json:"object_kind"`
Ref string `json:"ref"`
Tag bool `json:"tag"`
BeforeSHA string `json:"before_sha"`
SHA string `json:"sha"`
BuildID int `json:"build_id"`
BuildName string `json:"build_name"`
BuildStage string `json:"build_stage"`
BuildStatus string `json:"build_status"`
BuildStartedAt string `json:"build_started_at"`
BuildFinishedAt string `json:"build_finished_at"`
BuildDuration float64 `json:"build_duration"`
BuildAllowFailure bool `json:"build_allow_failure"`
PipelineID int `json:"pipeline_id"`
ProjectID int `json:"project_id"`
ProjectName string `json:"project_name"`
User struct {
ObjectKind string `json:"object_kind"`
Ref string `json:"ref"`
Tag bool `json:"tag"`
BeforeSHA string `json:"before_sha"`
SHA string `json:"sha"`
BuildID int `json:"build_id"`
BuildName string `json:"build_name"`
BuildStage string `json:"build_stage"`
BuildStatus string `json:"build_status"`
BuildStartedAt string `json:"build_started_at"`
BuildFinishedAt string `json:"build_finished_at"`
BuildDuration float64 `json:"build_duration"`
BuildAllowFailure bool `json:"build_allow_failure"`
BuildFailureReason string `json:"build_failure_reason"`
PipelineID int `json:"pipeline_id"`
ProjectID int `json:"project_id"`
ProjectName string `json:"project_name"`
User struct {
ID int `json:"id"`
Name string `json:"name"`
Email string `json:"email"`
@ -226,6 +235,12 @@ type JobEvent struct {
FinishedAt string `json:"finished_at"`
} `json:"commit"`
Repository *Repository `json:"repository"`
Runner struct {
ID int `json:"id"`
Active bool `json:"active"`
Shared bool `json:"is_shared"`
Description string `json:"description"`
} `json:"runner"`
}
// CommitCommentEvent represents a comment on a commit event.
@ -314,21 +329,30 @@ type MergeCommentEvent struct {
Visibility VisibilityValue `json:"visibility"`
} `json:"project"`
ObjectAttributes struct {
ID int `json:"id"`
DiscussionID string `json:"discussion_id"`
Note string `json:"note"`
NoteableType string `json:"noteable_type"`
AuthorID int `json:"author_id"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
ProjectID int `json:"project_id"`
Attachment string `json:"attachment"`
LineCode string `json:"line_code"`
CommitID string `json:"commit_id"`
NoteableID int `json:"noteable_id"`
System bool `json:"system"`
StDiff *Diff `json:"st_diff"`
URL string `json:"url"`
Attachment string `json:"attachment"`
AuthorID int `json:"author_id"`
ChangePosition *NotePosition `json:"change_position"`
CommitID string `json:"commit_id"`
CreatedAt string `json:"created_at"`
DiscussionID string `json:"discussion_id"`
ID int `json:"id"`
LineCode string `json:"line_code"`
Note string `json:"note"`
NoteableID int `json:"noteable_id"`
NoteableType string `json:"noteable_type"`
OriginalPosition *NotePosition `json:"original_position"`
Position *NotePosition `json:"position"`
ProjectID int `json:"project_id"`
ResolvedAt string `json:"resolved_at"`
ResolvedByID string `json:"resolved_by_id"`
ResolvedByPush string `json:"resolved_by_push"`
StDiff *Diff `json:"st_diff"`
System bool `json:"system"`
Type string `json:"type"`
UpdatedAt string `json:"updated_at"`
UpdatedByID string `json:"updated_by_id"`
Description string `json:"description"`
URL string `json:"url"`
} `json:"object_attributes"`
Repository *Repository `json:"repository"`
MergeRequest struct {
@ -614,6 +638,10 @@ type MergeEvent struct {
Previous int `json:"previous"`
Current int `json:"current"`
} `json:"updated_by_id"`
MilestoneID struct {
Previous int `json:"previous"`
Current int `json:"current"`
} `json:"milestone_id"`
} `json:"changes"`
}
@ -716,6 +744,7 @@ type PipelineEvent struct {
Tag bool `json:"tag"`
SHA string `json:"sha"`
BeforeSHA string `json:"before_sha"`
Source string `json:"source"`
Status string `json:"status"`
Stages []string `json:"stages"`
CreatedAt string `json:"created_at"`
@ -832,3 +861,43 @@ type BuildEvent struct {
} `json:"commit"`
Repository *Repository `json:"repository"`
}
// DeploymentEvent represents a deployment event
//
// GitLab API docs:
// https://docs.gitlab.com/ce/user/project/integrations/webhooks.html#deployment-events
type DeploymentEvent struct {
ObjectKind string `json:"object_kind"`
Status string `json:"status"`
DeployableID int `json:"deployable_id"`
DeployableURL string `json:"deployable_url"`
Environment string `json:"environment"`
Project struct {
ID int `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
WebURL string `json:"web_url"`
AvatarURL *string `json:"avatar_url"`
GitSSHURL string `json:"git_ssh_url"`
GitHTTPURL string `json:"git_http_url"`
Namespace string `json:"namespace"`
VisibilityLevel int `json:"visibility_level"`
PathWithNamespace string `json:"path_with_namespace"`
DefaultBranch string `json:"default_branch"`
CIConfigPath string `json:"ci_config_path"`
Homepage string `json:"homepage"`
URL string `json:"url"`
SSHURL string `json:"ssh_url"`
HTTPURL string `json:"http_url"`
} `json:"project"`
ShortSHA string `json:"short_sha"`
User struct {
Name string `json:"name"`
Username string `json:"username"`
AvatarURL string `json:"avatar_url"`
Email string `json:"email"`
} `json:"user"`
UserURL string `json:"user_url"`
CommitURL string `json:"commit_url"`
CommitTitle string `json:"commit_title"`
}

View file

@ -34,6 +34,7 @@ type EventsService struct {
// GitLab API docs:
// https://docs.gitlab.com/ce/api/events.html#get-user-contribution-events
type ContributionEvent struct {
ID int `json:"id"`
Title string `json:"title"`
ProjectID int `json:"project_id"`
ActionName string `json:"action_name"`

View file

@ -117,6 +117,7 @@ type Client struct {
Epics *EpicsService
Events *EventsService
Features *FeaturesService
FreezePeriods *FreezePeriodsService
GitIgnoreTemplates *GitIgnoreTemplatesService
GroupBadges *GroupBadgesService
GroupCluster *GroupClustersService
@ -280,6 +281,7 @@ func newClient(options ...ClientOptionFunc) (*Client, error) {
c.Epics = &EpicsService{client: c}
c.Events = &EventsService{client: c}
c.Features = &FeaturesService{client: c}
c.FreezePeriods = &FreezePeriodsService{client: c}
c.GitIgnoreTemplates = &GitIgnoreTemplatesService{client: c}
c.GroupBadges = &GroupBadgesService{client: c}
c.GroupCluster = &GroupClustersService{client: c}
@ -290,6 +292,7 @@ func newClient(options ...ClientOptionFunc) (*Client, error) {
c.GroupVariables = &GroupVariablesService{client: c}
c.Groups = &GroupsService{client: c}
c.InstanceCluster = &InstanceClustersService{client: c}
c.InstanceVariables = &InstanceVariablesService{client: c}
c.IssueLinks = &IssueLinksService{client: c}
c.Issues = &IssuesService{client: c, timeStats: timeStats}
c.IssuesStatistics = &IssuesStatisticsService{client: c}
@ -425,7 +428,7 @@ func (c *Client) configureLimiter() error {
if v := resp.Header.Get(headerRateLimit); v != "" {
if rateLimit, _ := strconv.ParseFloat(v, 64); rateLimit > 0 {
// The rate limit is based on requests per minute, so for our limiter to
// work correctly we devide the limit by 60 to get the limit per second.
// work correctly we divide the limit by 60 to get the limit per second.
rateLimit /= 60
// Configure the limit and burst using a split of 2/3 for the limit and
// 1/3 for the burst. This enables clients to burst 1/3 of the allowed

View file

@ -38,6 +38,7 @@ type GroupHook struct {
JobEvents bool `json:"job_events"`
PipelineEvents bool `json:"pipeline_events"`
WikiPageEvents bool `json:"wiki_page_events"`
DeploymentEvents bool `json:"deployment_events"`
EnableSSLVerification bool `json:"enable_ssl_verification"`
CreatedAt *time.Time `json:"created_at"`
}
@ -105,6 +106,7 @@ type AddGroupHookOptions struct {
JobEvents *bool `url:"job_events,omitempty" json:"job_events,omitempty"`
PipelineEvents *bool `url:"pipeline_events,omitempty" json:"pipeline_events,omitempty"`
WikiPageEvents *bool `url:"wiki_page_events,omitempty" json:"wiki_page_events,omitempty"`
DeploymentEvents *bool `url:"deployment_events,omitempty" json:"deployment_events,omitempty"`
EnableSSLVerification *bool `url:"enable_ssl_verification,omitempty" json:"enable_ssl_verification,omitempty"`
Token *string `url:"token,omitempty" json:"token,omitempty"`
}
@ -149,6 +151,7 @@ type EditGroupHookOptions struct {
JobEvents *bool `url:"job_events,omitempty" json:"job_events,omitempty"`
PipelineEvents *bool `url:"pipeline_events,omitempty" json:"pipeline_events,omitempty"`
WikiPageEvents *bool `url:"wiki_page_events,omitempty" json:"wiki_page_events,omitempty"`
DeploymentEvents *bool `url:"deployment_events,omitempty" json:"deployment_events,omitempty"`
EnableSSLVerification *bool `url:"enable_ssl_verification,omitempty" json:"enable_ssl_verification,omitempty"`
Token *string `url:"token,omitempty" json:"token,omitempty"`
}

View file

@ -251,6 +251,10 @@ func (s *GroupMilestonesService) GetGroupMilestoneMergeRequests(gid interface{},
return mr, resp, err
}
// BurndownChartEvent reprensents a burnout chart event
//
// GitLab API docs:
// https://docs.gitlab.com/ee/api/group_milestones.html#get-all-burndown-chart-events-for-a-single-milestone-starter
type BurndownChartEvent struct {
CreatedAt *time.Time `json:"created_at"`
Weight *int `json:"weight"`

View file

@ -75,6 +75,9 @@ type Group struct {
CreatedAt *time.Time `json:"created_at"`
}
// LDAPGroupLink represents a GitLab LDAP group link.
//
// GitLab API docs: https://docs.gitlab.com/ce/api/groups.html#ldap-group-links
type LDAPGroupLink struct {
CN string `json:"cn"`
GroupAccess AccessLevelValue `json:"group_access"`
@ -263,6 +266,31 @@ func (s *GroupsService) DeleteGroup(gid interface{}, options ...RequestOptionFun
return s.client.Do(req, nil)
}
// RestoreGroup restores a previously deleted group
//
// GitLap API docs:
// https://docs.gitlab.com/ee/api/groups.html#restore-group-marked-for-deletion
func (s *GroupsService) RestoreGroup(gid interface{}, options ...RequestOptionFunc) (*Group, *Response, error) {
group, err := parseID(gid)
if err != nil {
return nil, nil, err
}
u := fmt.Sprintf("groups/%s/restore", pathEscape(group))
req, err := s.client.NewRequest("POST", u, nil, options)
if err != nil {
return nil, nil, err
}
g := new(Group)
resp, err := s.client.Do(req, g)
if err != nil {
return nil, resp, err
}
return g, resp, nil
}
// SearchGroup get all groups that match your string in their name or path.
//
// GitLab API docs: https://docs.gitlab.com/ce/api/groups.html#search-for-group
@ -338,7 +366,7 @@ func (s *GroupsService) ListGroupProjects(gid interface{}, opt *ListGroupProject
// https://docs.gitlab.com/ce/api/groups.html#list-a-groups-s-subgroups
type ListSubgroupsOptions ListGroupsOptions
// ListSubgroups gets a list of subgroups for a given project.
// ListSubgroups gets a list of subgroups for a given group.
//
// GitLab API docs:
// https://docs.gitlab.com/ce/api/groups.html#list-a-groups-s-subgroups

View file

@ -34,6 +34,7 @@ type IssueLinksService struct {
type IssueLink struct {
SourceIssue *Issue `json:"source_issue"`
TargetIssue *Issue `json:"target_issue"`
LinkType string `json:"link_type"`
}
// ListIssueRelations gets a list of related issues of a given issue,
@ -70,6 +71,7 @@ func (s *IssueLinksService) ListIssueRelations(pid interface{}, issueIID int, op
type CreateIssueLinkOptions struct {
TargetProjectID *string `json:"target_project_id"`
TargetIssueIID *string `json:"target_issue_iid"`
LinkType *string `json:"link_type"`
}
// CreateIssueLink creates a two-way relation between two issues.

View file

@ -125,6 +125,7 @@ func (i Issue) String() string {
return Stringify(i)
}
// UnmarshalJSON implements the json.Unmarshaler interface.
func (i *Issue) UnmarshalJSON(data []byte) error {
type alias Issue

View file

@ -19,7 +19,6 @@ package gitlab
import (
"bytes"
"fmt"
"io"
"time"
)
@ -76,6 +75,29 @@ type Job struct {
User *User `json:"user"`
}
// Bridge represents a pipeline bridge.
//
// GitLab API docs: https://docs.gitlab.com/ce/api/jobs.html#list-pipeline-bridges
type Bridge struct {
Commit *Commit `json:"commit"`
Coverage float64 `json:"coverage"`
AllowFailure bool `json:"allow_failure"`
CreatedAt *time.Time `json:"created_at"`
StartedAt *time.Time `json:"started_at"`
FinishedAt *time.Time `json:"finished_at"`
Duration float64 `json:"duration"`
ID int `json:"id"`
Name string `json:"name"`
Pipeline PipelineInfo `json:"pipeline"`
Ref string `json:"ref"`
Stage string `json:"stage"`
Status string `json:"status"`
Tag bool `json:"tag"`
WebURL string `json:"web_url"`
User *User `json:"user"`
DownstreamPipeline *PipelineInfo `json:"downstream_pipeline"`
}
// ListJobsOptions are options for two list apis
type ListJobsOptions struct {
ListOptions
@ -89,7 +111,7 @@ type ListJobsOptions struct {
//
// GitLab API docs:
// https://docs.gitlab.com/ce/api/jobs.html#list-project-jobs
func (s *JobsService) ListProjectJobs(pid interface{}, opts *ListJobsOptions, options ...RequestOptionFunc) ([]Job, *Response, error) {
func (s *JobsService) ListProjectJobs(pid interface{}, opts *ListJobsOptions, options ...RequestOptionFunc) ([]*Job, *Response, error) {
project, err := parseID(pid)
if err != nil {
return nil, nil, err
@ -101,7 +123,7 @@ func (s *JobsService) ListProjectJobs(pid interface{}, opts *ListJobsOptions, op
return nil, nil, err
}
var jobs []Job
var jobs []*Job
resp, err := s.client.Do(req, &jobs)
if err != nil {
return nil, resp, err
@ -136,6 +158,32 @@ func (s *JobsService) ListPipelineJobs(pid interface{}, pipelineID int, opts *Li
return jobs, resp, err
}
// ListPipelineBridges gets a list of bridges for specific pipeline in a
// project.
//
// GitLab API docs:
// https://docs.gitlab.com/ce/api/jobs.html#list-pipeline-jobs
func (s *JobsService) ListPipelineBridges(pid interface{}, pipelineID int, opts *ListJobsOptions, options ...RequestOptionFunc) ([]*Bridge, *Response, error) {
project, err := parseID(pid)
if err != nil {
return nil, nil, err
}
u := fmt.Sprintf("projects/%s/pipelines/%d/bridges", pathEscape(project), pipelineID)
req, err := s.client.NewRequest("GET", u, opts, options)
if err != nil {
return nil, nil, err
}
var bridges []*Bridge
resp, err := s.client.Do(req, &bridges)
if err != nil {
return nil, resp, err
}
return bridges, resp, err
}
// GetJob gets a single job of a project.
//
// GitLab API docs:
@ -165,7 +213,7 @@ func (s *JobsService) GetJob(pid interface{}, jobID int, options ...RequestOptio
//
// GitLab API docs:
// https://docs.gitlab.com/ce/api/job_artifacts.html#get-job-artifacts
func (s *JobsService) GetJobArtifacts(pid interface{}, jobID int, options ...RequestOptionFunc) (io.Reader, *Response, error) {
func (s *JobsService) GetJobArtifacts(pid interface{}, jobID int, options ...RequestOptionFunc) (*bytes.Reader, *Response, error) {
project, err := parseID(pid)
if err != nil {
return nil, nil, err
@ -183,7 +231,7 @@ func (s *JobsService) GetJobArtifacts(pid interface{}, jobID int, options ...Req
return nil, resp, err
}
return artifactsBuf, resp, err
return bytes.NewReader(artifactsBuf.Bytes()), resp, err
}
// DownloadArtifactsFileOptions represents the available DownloadArtifactsFile()
@ -200,7 +248,7 @@ type DownloadArtifactsFileOptions struct {
//
// GitLab API docs:
// https://docs.gitlab.com/ce/api/job_artifacts.html#download-the-artifacts-archive
func (s *JobsService) DownloadArtifactsFile(pid interface{}, refName string, opt *DownloadArtifactsFileOptions, options ...RequestOptionFunc) (io.Reader, *Response, error) {
func (s *JobsService) DownloadArtifactsFile(pid interface{}, refName string, opt *DownloadArtifactsFileOptions, options ...RequestOptionFunc) (*bytes.Reader, *Response, error) {
project, err := parseID(pid)
if err != nil {
return nil, nil, err
@ -218,7 +266,7 @@ func (s *JobsService) DownloadArtifactsFile(pid interface{}, refName string, opt
return nil, resp, err
}
return artifactsBuf, resp, err
return bytes.NewReader(artifactsBuf.Bytes()), resp, err
}
// DownloadSingleArtifactsFile download a file from the artifacts from the
@ -228,7 +276,7 @@ func (s *JobsService) DownloadArtifactsFile(pid interface{}, refName string, opt
//
// GitLab API docs:
// https://docs.gitlab.com/ce/api/job_artifacts.html#download-a-single-artifact-file-by-job-id
func (s *JobsService) DownloadSingleArtifactsFile(pid interface{}, jobID int, artifactPath string, options ...RequestOptionFunc) (io.Reader, *Response, error) {
func (s *JobsService) DownloadSingleArtifactsFile(pid interface{}, jobID int, artifactPath string, options ...RequestOptionFunc) (*bytes.Reader, *Response, error) {
project, err := parseID(pid)
if err != nil {
return nil, nil, err
@ -252,14 +300,14 @@ func (s *JobsService) DownloadSingleArtifactsFile(pid interface{}, jobID int, ar
return nil, resp, err
}
return artifactBuf, resp, err
return bytes.NewReader(artifactBuf.Bytes()), resp, err
}
// GetTraceFile gets a trace of a specific job of a project
//
// GitLab API docs:
// https://docs.gitlab.com/ce/api/jobs.html#get-a-trace-file
func (s *JobsService) GetTraceFile(pid interface{}, jobID int, options ...RequestOptionFunc) (io.Reader, *Response, error) {
func (s *JobsService) GetTraceFile(pid interface{}, jobID int, options ...RequestOptionFunc) (*bytes.Reader, *Response, error) {
project, err := parseID(pid)
if err != nil {
return nil, nil, err
@ -277,7 +325,7 @@ func (s *JobsService) GetTraceFile(pid interface{}, jobID int, options ...Reques
return nil, resp, err
}
return traceBuf, resp, err
return bytes.NewReader(traceBuf.Bytes()), resp, err
}
// CancelJob cancels a single job of a project.

View file

@ -70,18 +70,29 @@ type Note struct {
// NotePosition represents the position attributes of a note.
type NotePosition struct {
BaseSHA string `json:"base_sha"`
StartSHA string `json:"start_sha"`
HeadSHA string `json:"head_sha"`
PositionType string `json:"position_type"`
NewPath string `json:"new_path,omitempty"`
NewLine int `json:"new_line,omitempty"`
OldPath string `json:"old_path,omitempty"`
OldLine int `json:"old_line,omitempty"`
Width int `json:"width,omitempty"`
Height int `json:"height,omitempty"`
X int `json:"x,omitempty"`
Y int `json:"y,omitempty"`
BaseSHA string `json:"base_sha"`
StartSHA string `json:"start_sha"`
HeadSHA string `json:"head_sha"`
PositionType string `json:"position_type"`
NewPath string `json:"new_path,omitempty"`
NewLine int `json:"new_line,omitempty"`
OldPath string `json:"old_path,omitempty"`
OldLine int `json:"old_line,omitempty"`
LineRange *LineRange `json:"line_range"`
}
// LineRange represents the range of a note.
type LineRange struct {
StartRange *LinePosition `json:"start"`
EndRange *LinePosition `json:"end"`
}
// LinePosition represents a position in a line range.
type LinePosition struct {
LineCode string `json:"line_code"`
Type string `json:"type"`
OldLine int `json:"old_line"`
NewLine int `json:"new_line"`
}
func (n Note) String() string {

View file

@ -105,10 +105,21 @@ type PipelineTestSuites struct {
// PipelineTestCases contains test cases details.
type PipelineTestCases struct {
Status string `json:"status"`
Name string `json:"name"`
Classname string `json:"classname"`
ExecutionTime float64 `json:"execution_time"`
Status string `json:"status"`
Name string `json:"name"`
Classname string `json:"classname"`
File string `json:"file"`
ExecutionTime float64 `json:"execution_time"`
SystemOutput string `json:"system_output"`
StackTrace string `json:"stack_trace"`
AttachmentURL string `json:"attachment_url"`
RecentFailures RecentFailures `json:"recent_failures"`
}
// RecentFailures contains failures count for the project's default branch.
type RecentFailures struct {
Count int `json:"count"`
BaseBranch string `json:"base_branch"`
}
func (p PipelineTestReport) String() string {

View file

@ -68,7 +68,6 @@ func (s *ProjectMirrorService) ListProjectMirror(pid interface{}, options ...Req
}
return pm, resp, err
}
// AddProjectMirrorOptions contains the properties requires to create

View file

@ -77,6 +77,7 @@ type Project struct {
StarCount int `json:"star_count"`
RunnersToken string `json:"runners_token"`
PublicBuilds bool `json:"public_builds"`
AllowMergeOnSkippedPipeline bool `json:"allow_merge_on_skipped_pipeline"`
OnlyAllowMergeIfPipelineSucceeds bool `json:"only_allow_merge_if_pipeline_succeeds"`
OnlyAllowMergeIfAllDiscussionsAreResolved bool `json:"only_allow_merge_if_all_discussions_are_resolved"`
RemoveSourceBranchAfterMerge bool `json:"remove_source_branch_after_merge"`
@ -101,6 +102,7 @@ type Project struct {
SnippetsAccessLevel AccessControlValue `json:"snippets_access_level"`
PagesAccessLevel AccessControlValue `json:"pages_access_level"`
AutocloseReferencedIssues bool `json:"autoclose_referenced_issues"`
CIForwardDeploymentEnabled bool `json:"ci_forward_deployment_enabled"`
SharedWithGroups []struct {
GroupID int `json:"group_id"`
GroupName string `json:"group_name"`
@ -486,6 +488,7 @@ type CreateProjectOptions struct {
Visibility *VisibilityValue `url:"visibility,omitempty" json:"visibility,omitempty"`
ImportURL *string `url:"import_url,omitempty" json:"import_url,omitempty"`
PublicBuilds *bool `url:"public_builds,omitempty" json:"public_builds,omitempty"`
AllowMergeOnSkippedPipeline *bool `url:"allow_merge_on_skipped_pipeline,omitempty" json:"allow_merge_on_skipped_pipeline,omitempty"`
OnlyAllowMergeIfPipelineSucceeds *bool `url:"only_allow_merge_if_pipeline_succeeds,omitempty" json:"only_allow_merge_if_pipeline_succeeds,omitempty"`
OnlyAllowMergeIfAllDiscussionsAreResolved *bool `url:"only_allow_merge_if_all_discussions_are_resolved,omitempty" json:"only_allow_merge_if_all_discussions_are_resolved,omitempty"`
MergeMethod *MergeMethodValue `url:"merge_method,omitempty" json:"merge_method,omitempty"`
@ -499,6 +502,7 @@ type CreateProjectOptions struct {
AutoCancelPendingPipelines *string `url:"auto_cancel_pending_pipelines,omitempty" json:"auto_cancel_pending_pipelines,omitempty"`
BuildCoverageRegex *string `url:"build_coverage_regex,omitempty" json:"build_coverage_regex,omitempty"`
CIConfigPath *string `url:"ci_config_path,omitempty" json:"ci_config_path,omitempty"`
CIForwardDeploymentEnabled *bool `url:"ci_forward_deployment_enabled,omitempty" json:"ci_forward_deployment_enabled,omitempty"`
AutoDevopsEnabled *bool `url:"auto_devops_enabled,omitempty" json:"auto_devops_enabled,omitempty"`
AutoDevopsDeployStrategy *string `url:"auto_devops_deploy_strategy,omitempty" json:"auto_devops_deploy_strategy,omitempty"`
ApprovalsBeforeMerge *int `url:"approvals_before_merge,omitempty" json:"approvals_before_merge,omitempty"`
@ -592,6 +596,7 @@ type EditProjectOptions struct {
Visibility *VisibilityValue `url:"visibility,omitempty" json:"visibility,omitempty"`
ImportURL *string `url:"import_url,omitempty" json:"import_url,omitempty"`
PublicBuilds *bool `url:"public_builds,omitempty" json:"public_builds,omitempty"`
AllowMergeOnSkippedPipeline *bool `url:"allow_merge_on_skipped_pipeline,omitempty" json:"allow_merge_on_skipped_pipeline,omitempty"`
OnlyAllowMergeIfPipelineSucceeds *bool `url:"only_allow_merge_if_pipeline_succeeds,omitempty" json:"only_allow_merge_if_pipeline_succeeds,omitempty"`
OnlyAllowMergeIfAllDiscussionsAreResolved *bool `url:"only_allow_merge_if_all_discussions_are_resolved,omitempty" json:"only_allow_merge_if_all_discussions_are_resolved,omitempty"`
MergeMethod *MergeMethodValue `url:"merge_method,omitempty" json:"merge_method,omitempty"`
@ -604,6 +609,7 @@ type EditProjectOptions struct {
AutoCancelPendingPipelines *string `url:"auto_cancel_pending_pipelines,omitempty" json:"auto_cancel_pending_pipelines,omitempty"`
BuildCoverageRegex *string `url:"build_coverage_regex,omitempty" json:"build_coverage_regex,omitempty"`
CIConfigPath *string `url:"ci_config_path,omitempty" json:"ci_config_path,omitempty"`
CIForwardDeploymentEnabled *bool `url:"ci_forward_deployment_enabled,omitempty" json:"ci_forward_deployment_enabled,omitempty"`
CIDefaultGitDepth *int `url:"ci_default_git_depth,omitempty" json:"ci_default_git_depth,omitempty"`
AutoDevopsEnabled *bool `url:"auto_devops_enabled,omitempty" json:"auto_devops_enabled,omitempty"`
AutoDevopsDeployStrategy *string `url:"auto_devops_deploy_strategy,omitempty" json:"auto_devops_deploy_strategy,omitempty"`
@ -886,6 +892,7 @@ type ProjectHook struct {
JobEvents bool `json:"job_events"`
PipelineEvents bool `json:"pipeline_events"`
WikiPageEvents bool `json:"wiki_page_events"`
DeploymentEvents bool `json:"deployment_events"`
EnableSSLVerification bool `json:"enable_ssl_verification"`
CreatedAt *time.Time `json:"created_at"`
}
@ -962,6 +969,7 @@ type AddProjectHookOptions struct {
JobEvents *bool `url:"job_events,omitempty" json:"job_events,omitempty"`
PipelineEvents *bool `url:"pipeline_events,omitempty" json:"pipeline_events,omitempty"`
WikiPageEvents *bool `url:"wiki_page_events,omitempty" json:"wiki_page_events,omitempty"`
DeploymentEvents *bool `url:"deployment_events,omitempty" json:"deployment_events,omitempty"`
EnableSSLVerification *bool `url:"enable_ssl_verification,omitempty" json:"enable_ssl_verification,omitempty"`
Token *string `url:"token,omitempty" json:"token,omitempty"`
}
@ -1008,6 +1016,7 @@ type EditProjectHookOptions struct {
JobEvents *bool `url:"job_events,omitempty" json:"job_events,omitempty"`
PipelineEvents *bool `url:"pipeline_events,omitempty" json:"pipeline_events,omitempty"`
WikiPageEvents *bool `url:"wiki_page_events,omitempty" json:"wiki_page_events,omitempty"`
DeploymentEvents *bool `url:"deployment_events,omitempty" json:"deployment_events,omitempty"`
EnableSSLVerification *bool `url:"enable_ssl_verification,omitempty" json:"enable_ssl_verification,omitempty"`
Token *string `url:"token,omitempty" json:"token,omitempty"`
}

View file

@ -124,7 +124,9 @@ type CreateReleaseOptions struct {
TagName *string `url:"tag_name" json:"tag_name"`
Description *string `url:"description" json:"description"`
Ref *string `url:"ref,omitempty" json:"ref,omitempty"`
Milestones []string `url:"milestones,omitempty" json:"milestones,omitempty"`
Assets *ReleaseAssets `url:"assets,omitempty" json:"assets,omitempty"`
ReleasedAt *time.Time `url:"released_at,omitempty" json:"released_at,omitempty"`
}
// CreateRelease creates a release.
@ -157,8 +159,10 @@ func (s *ReleasesService) CreateRelease(pid interface{}, opts *CreateReleaseOpti
// GitLab API docs:
// https://docs.gitlab.com/ce/api/releases/index.html#update-a-release
type UpdateReleaseOptions struct {
Name *string `url:"name" json:"name"`
Description *string `url:"description" json:"description"`
Name *string `url:"name" json:"name"`
Description *string `url:"description" json:"description"`
Milestones []string `url:"milestones,omitempty" json:"milestones,omitempty"`
ReleasedAt *time.Time `url:"released_at,omitempty" json:"released_at,omitempty"`
}
// UpdateRelease updates a release.

View file

@ -260,6 +260,7 @@ func (r FileInfo) String() string {
// https://docs.gitlab.com/ce/api/repository_files.html#create-new-file-in-repository
type CreateFileOptions struct {
Branch *string `url:"branch,omitempty" json:"branch,omitempty"`
StartBranch *string `url:"start_branch,omitempty" json:"start_branch,omitempty"`
Encoding *string `url:"encoding,omitempty" json:"encoding,omitempty"`
AuthorEmail *string `url:"author_email,omitempty" json:"author_email,omitempty"`
AuthorName *string `url:"author_name,omitempty" json:"author_name,omitempty"`
@ -302,6 +303,7 @@ func (s *RepositoryFilesService) CreateFile(pid interface{}, fileName string, op
// https://docs.gitlab.com/ce/api/repository_files.html#update-existing-file-in-repository
type UpdateFileOptions struct {
Branch *string `url:"branch,omitempty" json:"branch,omitempty"`
StartBranch *string `url:"start_branch,omitempty" json:"start_branch,omitempty"`
Encoding *string `url:"encoding,omitempty" json:"encoding,omitempty"`
AuthorEmail *string `url:"author_email,omitempty" json:"author_email,omitempty"`
AuthorName *string `url:"author_name,omitempty" json:"author_name,omitempty"`

View file

@ -69,6 +69,7 @@ type RunnerDetails struct {
Token string `json:"token"`
Revision string `json:"revision"`
TagList []string `json:"tag_list"`
RunUntagged bool `json:"run_untagged"`
Version string `json:"version"`
Locked bool `json:"locked"`
AccessLevel string `json:"access_level"`
@ -380,14 +381,27 @@ func (s *RunnersService) ListGroupsRunners(gid interface{}, opt *ListGroupsRunne
// GitLab API docs:
// https://docs.gitlab.com/ce/api/runners.html#register-a-new-runner
type RegisterNewRunnerOptions struct {
Token *string `url:"token" json:"token"`
Description *string `url:"description,omitempty" json:"description,omitempty"`
Info *string `url:"info,omitempty" json:"info,omitempty"`
Active *bool `url:"active,omitempty" json:"active,omitempty"`
Locked *bool `url:"locked,omitempty" json:"locked,omitempty"`
RunUntagged *bool `url:"run_untagged,omitempty" json:"run_untagged,omitempty"`
TagList []string `url:"tag_list[],omitempty" json:"tag_list,omitempty"`
MaximumTimeout *int `url:"maximum_timeout,omitempty" json:"maximum_timeout,omitempty"`
Token *string `url:"token" json:"token"`
Description *string `url:"description,omitempty" json:"description,omitempty"`
Info *RegisterNewRunnerInfoOptions `url:"info,omitempty" json:"info,omitempty"`
Active *bool `url:"active,omitempty" json:"active,omitempty"`
Locked *bool `url:"locked,omitempty" json:"locked,omitempty"`
RunUntagged *bool `url:"run_untagged,omitempty" json:"run_untagged,omitempty"`
TagList []string `url:"tag_list[],omitempty" json:"tag_list,omitempty"`
MaximumTimeout *int `url:"maximum_timeout,omitempty" json:"maximum_timeout,omitempty"`
}
// RegisterNewRunnerInfoOptions represents the info hashmap parameter in
// RegisterNewRunnerOptions.
//
// GitLab API docs:
// https://docs.gitlab.com/ce/api/runners.html#register-a-new-runner
type RegisterNewRunnerInfoOptions struct {
Name *string `url:"name,omitempty" json:"name,omitempty"`
Version *string `url:"version,omitempty" json:"version,omitempty"`
Revision *string `url:"revision,omitempty" json:"revision,omitempty"`
Platform *string `url:"platform,omitempty" json:"platform,omitempty"`
Architecture *string `url:"architecture,omitempty" json:"architecture,omitempty"`
}
// RegisterNewRunner registers a new Runner for the instance.
@ -418,10 +432,10 @@ type DeleteRegisteredRunnerOptions struct {
Token *string `url:"token" json:"token"`
}
// DeleteRegisteredRunner registers a new Runner for the instance.
// DeleteRegisteredRunner deletes a Runner by Token.
//
// GitLab API docs:
// https://docs.gitlab.com/ce/api/runners.html#delete-a-registered-runner
// https://docs.gitlab.com/ce/api/runners.html#delete-a-runner-by-authentication-token
func (s *RunnersService) DeleteRegisteredRunner(opt *DeleteRegisteredRunnerOptions, options ...RequestOptionFunc) (*Response, error) {
req, err := s.client.NewRequest("DELETE", "runners", opt, options)
if err != nil {
@ -431,6 +445,19 @@ func (s *RunnersService) DeleteRegisteredRunner(opt *DeleteRegisteredRunnerOptio
return s.client.Do(req, nil)
}
// DeleteRegisteredRunnerByID deletes a Runner by ID.
//
// GitLab API docs:
// https://docs.gitlab.com/ce/api/runners.html#delete-a-runner-by-id
func (s *RunnersService) DeleteRegisteredRunnerByID(rid int, options ...RequestOptionFunc) (*Response, error) {
req, err := s.client.NewRequest("DELETE", fmt.Sprintf("runners/%d", rid), nil, options)
if err != nil {
return nil, err
}
return s.client.Do(req, nil)
}
// VerifyRegisteredRunnerOptions represents the available
// VerifyRegisteredRunner() options.
//

View file

@ -52,6 +52,7 @@ type Service struct {
PipelineEvents bool `json:"pipeline_events"`
JobEvents bool `json:"job_events"`
WikiPageEvents bool `json:"wiki_page_events"`
DeploymentEvents bool `json:"deployment_events"`
}
// ListServices gets a list of all active services.

View file

@ -54,40 +54,43 @@ type BasicUser struct {
//
// GitLab API docs: https://docs.gitlab.com/ee/api/users.html
type User struct {
ID int `json:"id"`
Username string `json:"username"`
Email string `json:"email"`
Name string `json:"name"`
State string `json:"state"`
WebURL string `json:"web_url"`
CreatedAt *time.Time `json:"created_at"`
Bio string `json:"bio"`
Location string `json:"location"`
PublicEmail string `json:"public_email"`
Skype string `json:"skype"`
Linkedin string `json:"linkedin"`
Twitter string `json:"twitter"`
WebsiteURL string `json:"website_url"`
Organization string `json:"organization"`
ExternUID string `json:"extern_uid"`
Provider string `json:"provider"`
ThemeID int `json:"theme_id"`
LastActivityOn *ISOTime `json:"last_activity_on"`
ColorSchemeID int `json:"color_scheme_id"`
IsAdmin bool `json:"is_admin"`
AvatarURL string `json:"avatar_url"`
CanCreateGroup bool `json:"can_create_group"`
CanCreateProject bool `json:"can_create_project"`
ProjectsLimit int `json:"projects_limit"`
CurrentSignInAt *time.Time `json:"current_sign_in_at"`
LastSignInAt *time.Time `json:"last_sign_in_at"`
ConfirmedAt *time.Time `json:"confirmed_at"`
TwoFactorEnabled bool `json:"two_factor_enabled"`
Identities []*UserIdentity `json:"identities"`
External bool `json:"external"`
PrivateProfile bool `json:"private_profile"`
SharedRunnersMinutesLimit int `json:"shared_runners_minutes_limit"`
CustomAttributes []*CustomAttribute `json:"custom_attributes"`
ID int `json:"id"`
Username string `json:"username"`
Email string `json:"email"`
Name string `json:"name"`
State string `json:"state"`
WebURL string `json:"web_url"`
CreatedAt *time.Time `json:"created_at"`
Bio string `json:"bio"`
Location string `json:"location"`
PublicEmail string `json:"public_email"`
Skype string `json:"skype"`
Linkedin string `json:"linkedin"`
Twitter string `json:"twitter"`
WebsiteURL string `json:"website_url"`
Organization string `json:"organization"`
ExternUID string `json:"extern_uid"`
Provider string `json:"provider"`
ThemeID int `json:"theme_id"`
LastActivityOn *ISOTime `json:"last_activity_on"`
ColorSchemeID int `json:"color_scheme_id"`
IsAdmin bool `json:"is_admin"`
AvatarURL string `json:"avatar_url"`
CanCreateGroup bool `json:"can_create_group"`
CanCreateProject bool `json:"can_create_project"`
ProjectsLimit int `json:"projects_limit"`
CurrentSignInAt *time.Time `json:"current_sign_in_at"`
LastSignInAt *time.Time `json:"last_sign_in_at"`
ConfirmedAt *time.Time `json:"confirmed_at"`
TwoFactorEnabled bool `json:"two_factor_enabled"`
Note string `json:"note"`
Identities []*UserIdentity `json:"identities"`
External bool `json:"external"`
PrivateProfile bool `json:"private_profile"`
SharedRunnersMinutesLimit int `json:"shared_runners_minutes_limit"`
ExtraSharedRunnersMinutesLimit int `json:"extra_shared_runners_minutes_limit"`
UsingLicenseSeat bool `json:"using_license_seat"`
CustomAttributes []*CustomAttribute `json:"custom_attributes"`
}
// UserIdentity represents a user identity.
@ -101,8 +104,9 @@ type UserIdentity struct {
// GitLab API docs: https://docs.gitlab.com/ce/api/users.html#list-users
type ListUsersOptions struct {
ListOptions
Active *bool `url:"active,omitempty" json:"active,omitempty"`
Blocked *bool `url:"blocked,omitempty" json:"blocked,omitempty"`
Active *bool `url:"active,omitempty" json:"active,omitempty"`
Blocked *bool `url:"blocked,omitempty" json:"blocked,omitempty"`
ExcludeInternal *bool `url:"exclude_internal,omitempty" json:"exclude_internal,omitempty"`
// The options below are only available for admins.
Search *string `url:"search,omitempty" json:"search,omitempty"`
@ -362,8 +366,9 @@ func (s *UsersService) GetSSHKey(key int, options ...RequestOptionFunc) (*SSHKey
//
// GitLab API docs: https://docs.gitlab.com/ce/api/projects.html#add-ssh-key
type AddSSHKeyOptions struct {
Title *string `url:"title,omitempty" json:"title,omitempty"`
Key *string `url:"key,omitempty" json:"key,omitempty"`
Title *string `url:"title,omitempty" json:"title,omitempty"`
Key *string `url:"key,omitempty" json:"key,omitempty"`
ExpiresAt *ISOTime `url:"expires_at,omitempty" json:"expires_at,omitempty"`
}
// AddSSHKey creates a new key owned by the currently authenticated user.
@ -937,10 +942,10 @@ func (s *UsersService) SetUserStatus(opt *UserStatusOptions, options ...RequestO
// GitLab API docs:
// https://docs.gitlab.com/ee/api/users.html#user-memberships-admin-only
type UserMembership struct {
SourceID int `json:"source_id"`
SourceName string `json:"source_name"`
SourceType string `json:"source_type"`
AccessLevel string `json:"access_level"`
SourceID int `json:"source_id"`
SourceName string `json:"source_name"`
SourceType string `json:"source_type"`
AccessLevel AccessLevelValue `json:"access_level"`
}
// GetUserMembershipOptions represents the options available to query user memberships.

View file

@ -1,5 +1,7 @@
package gitlab
import "fmt"
// ValidateService handles communication with the validation related methods of
// the GitLab API.
//
@ -16,6 +18,17 @@ type LintResult struct {
Errors []string `json:"errors"`
}
// ProjectLintResult represents the linting results by project.
//
// GitLab API docs:
// https://docs.gitlab.com/ee/api/lint.html#validate-a-projects-ci-configuration
type ProjectLintResult struct {
Valid bool `json:"valid"`
Errors []string `json:"errors"`
Warnings []string `json:"warnings"`
MergedYaml string `json:"merged_yaml"`
}
// Lint validates .gitlab-ci.yml content.
//
// GitLab API docs: https://docs.gitlab.com/ce/api/lint.html
@ -38,3 +51,70 @@ func (s *ValidateService) Lint(content string, options ...RequestOptionFunc) (*L
return l, resp, nil
}
// ProjectNamespaceLintOptions represents the available ProjectNamespaceLint() options.
//
// GitLab API docs:
// https://docs.gitlab.com/ee/api/lint.html#validate-a-ci-yaml-configuration-with-a-namespace
type ProjectNamespaceLintOptions struct {
Content *string `url:"content,omitempty" json:"content,omitempty"`
DryRun *bool `url:"dry_run,omitempty" json:"dry_run,omitempty"`
}
// ProjectNamespaceLint validates .gitlab-ci.yml content by project.
//
// GitLab API docs:
// https://docs.gitlab.com/ee/api/lint.html#validate-a-ci-yaml-configuration-with-a-namespace
func (s *ValidateService) ProjectNamespaceLint(pid interface{}, opt *ProjectNamespaceLintOptions, options ...RequestOptionFunc) (*ProjectLintResult, *Response, error) {
project, err := parseID(pid)
if err != nil {
return nil, nil, err
}
u := fmt.Sprintf("projects/%s/ci/lint", pathEscape(project))
req, err := s.client.NewRequest("POST", u, &opt, options)
if err != nil {
return nil, nil, err
}
l := new(ProjectLintResult)
resp, err := s.client.Do(req, l)
if err != nil {
return nil, resp, err
}
return l, resp, nil
}
// ProjectLintOptions represents the available ProjectLint() options.
//
// GitLab API docs:
// https://docs.gitlab.com/ee/api/lint.html#validate-a-projects-ci-configuration
type ProjectLintOptions struct {
DryRun *bool `url:"dry_run,omitempty" json:"dry_run,omitempty"`
}
// ProjectLint validates .gitlab-ci.yml content by project.
//
// GitLab API docs:
// https://docs.gitlab.com/ee/api/lint.html#validate-a-projects-ci-configuration
func (s *ValidateService) ProjectLint(pid interface{}, opt *ProjectLintOptions, options ...RequestOptionFunc) (*ProjectLintResult, *Response, error) {
project, err := parseID(pid)
if err != nil {
return nil, nil, err
}
u := fmt.Sprintf("projects/%s/ci/lint", pathEscape(project))
req, err := s.client.NewRequest("GET", u, &opt, options)
if err != nil {
return nil, nil, err
}
l := new(ProjectLintResult)
resp, err := s.client.Do(req, l)
if err != nil {
return nil, resp, err
}
return l, resp, nil
}