diff options
Diffstat (limited to 'vendor/github.com/xanzy/go-gitlab/pipelines.go')
-rw-r--r-- | vendor/github.com/xanzy/go-gitlab/pipelines.go | 109 |
1 files changed, 69 insertions, 40 deletions
diff --git a/vendor/github.com/xanzy/go-gitlab/pipelines.go b/vendor/github.com/xanzy/go-gitlab/pipelines.go index 456de643..bf3f814b 100644 --- a/vendor/github.com/xanzy/go-gitlab/pipelines.go +++ b/vendor/github.com/xanzy/go-gitlab/pipelines.go @@ -41,39 +41,43 @@ type PipelineVariable struct { // // GitLab API docs: https://docs.gitlab.com/ce/api/pipelines.html type Pipeline struct { - ID int `json:"id"` - Status string `json:"status"` - Ref string `json:"ref"` - SHA string `json:"sha"` - BeforeSHA string `json:"before_sha"` - Tag bool `json:"tag"` - YamlErrors string `json:"yaml_errors"` - User struct { - Name string `json:"name"` - Username string `json:"username"` - ID int `json:"id"` - State string `json:"state"` - AvatarURL string `json:"avatar_url"` - WebURL string `json:"web_url"` - } - UpdatedAt *time.Time `json:"updated_at"` - CreatedAt *time.Time `json:"created_at"` - StartedAt *time.Time `json:"started_at"` - FinishedAt *time.Time `json:"finished_at"` - CommittedAt *time.Time `json:"committed_at"` - Duration int `json:"duration"` - Coverage string `json:"coverage"` - WebURL string `json:"web_url"` -} - -func (i Pipeline) String() string { - return Stringify(i) -} - -// PipelineList represents a GitLab list project pipelines -// -// GitLab API docs: https://docs.gitlab.com/ce/api/pipelines.html#list-project-pipelines -type PipelineList []*PipelineInfo + ID int `json:"id"` + Status string `json:"status"` + Ref string `json:"ref"` + SHA string `json:"sha"` + BeforeSHA string `json:"before_sha"` + Tag bool `json:"tag"` + YamlErrors string `json:"yaml_errors"` + User *BasicUser `json:"user"` + UpdatedAt *time.Time `json:"updated_at"` + CreatedAt *time.Time `json:"created_at"` + StartedAt *time.Time `json:"started_at"` + FinishedAt *time.Time `json:"finished_at"` + CommittedAt *time.Time `json:"committed_at"` + Duration int `json:"duration"` + Coverage string `json:"coverage"` + WebURL string `json:"web_url"` + DetailedStatus *DetailedStatus `json:"detailed_status"` +} + +// DetailedStatus contains detailed information about the status of a pipeline +type DetailedStatus struct { + Icon string `json:"icon"` + Text string `json:"text"` + Label string `json:"label"` + Group string `json:"group"` + Tooltip string `json:"tooltip"` + HasDetails bool `json:"has_details"` + DetailsPath string `json:"details_path"` + Illustration struct { + Image string `json:"image"` + } `json:"illustration"` + Favicon string `json:"favicon"` +} + +func (p Pipeline) String() string { + return Stringify(p) +} // PipelineInfo shows the basic entities of a pipeline, mostly used as fields // on other assets, like Commit. @@ -85,8 +89,8 @@ type PipelineInfo struct { WebURL string `json:"web_url"` } -func (i PipelineList) String() string { - return Stringify(i) +func (p PipelineInfo) String() string { + return Stringify(p) } // ListProjectPipelinesOptions represents the available ListProjectPipelines() options. @@ -108,7 +112,7 @@ type ListProjectPipelinesOptions struct { // ListProjectPipelines gets a list of project piplines. // // GitLab API docs: https://docs.gitlab.com/ce/api/pipelines.html#list-project-pipelines -func (s *PipelinesService) ListProjectPipelines(pid interface{}, opt *ListProjectPipelinesOptions, options ...OptionFunc) (PipelineList, *Response, error) { +func (s *PipelinesService) ListProjectPipelines(pid interface{}, opt *ListProjectPipelinesOptions, options ...OptionFunc) ([]*PipelineInfo, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err @@ -120,11 +124,12 @@ func (s *PipelinesService) ListProjectPipelines(pid interface{}, opt *ListProjec return nil, nil, err } - var p PipelineList + var p []*PipelineInfo resp, err := s.client.Do(req, &p) if err != nil { return nil, resp, err } + return p, resp, err } @@ -152,6 +157,30 @@ func (s *PipelinesService) GetPipeline(pid interface{}, pipeline int, options .. return p, resp, err } +// GetPipelineVariables gets the variables of a single project pipeline. +// +// GitLab API docs: https://docs.gitlab.com/ce/api/pipelines.html#get-variables-of-a-pipeline +func (s *PipelinesService) GetPipelineVariables(pid interface{}, pipeline int, options ...OptionFunc) ([]*PipelineVariable, *Response, error) { + project, err := parseID(pid) + if err != nil { + return nil, nil, err + } + u := fmt.Sprintf("projects/%s/pipelines/%d/variables", pathEscape(project), pipeline) + + req, err := s.client.NewRequest("GET", u, nil, options) + if err != nil { + return nil, nil, err + } + + var p []*PipelineVariable + resp, err := s.client.Do(req, &p) + if err != nil { + return nil, resp, err + } + + return p, resp, err +} + // CreatePipelineOptions represents the available CreatePipeline() options. // // GitLab API docs: https://docs.gitlab.com/ce/api/pipelines.html#create-a-new-pipeline @@ -193,7 +222,7 @@ func (s *PipelinesService) RetryPipelineBuild(pid interface{}, pipeline int, opt if err != nil { return nil, nil, err } - u := fmt.Sprintf("projects/%s/pipelines/%d/retry", project, pipeline) + u := fmt.Sprintf("projects/%s/pipelines/%d/retry", pathEscape(project), pipeline) req, err := s.client.NewRequest("POST", u, nil, options) if err != nil { @@ -218,7 +247,7 @@ func (s *PipelinesService) CancelPipelineBuild(pid interface{}, pipeline int, op if err != nil { return nil, nil, err } - u := fmt.Sprintf("projects/%s/pipelines/%d/cancel", project, pipeline) + u := fmt.Sprintf("projects/%s/pipelines/%d/cancel", pathEscape(project), pipeline) req, err := s.client.NewRequest("POST", u, nil, options) if err != nil { @@ -243,7 +272,7 @@ func (s *PipelinesService) DeletePipeline(pid interface{}, pipeline int, options if err != nil { return nil, err } - u := fmt.Sprintf("projects/%s/pipelines/%d", project, pipeline) + u := fmt.Sprintf("projects/%s/pipelines/%d", pathEscape(project), pipeline) req, err := s.client.NewRequest("DELETE", u, nil, options) if err != nil { |