1package gitlab
2
3// ValidateService handles communication with the validation related methods of
4// the GitLab API.
5//
6// GitLab API docs: https://docs.gitlab.com/ce/api/lint.html
7type ValidateService struct {
8 client *Client
9}
10
11// LintResult represents the linting results.
12//
13// GitLab API docs: https://docs.gitlab.com/ce/api/lint.html
14type LintResult struct {
15 Status string `json:"status"`
16 Errors []string `json:"errors"`
17}
18
19// Lint validates .gitlab-ci.yml content.
20//
21// GitLab API docs: https://docs.gitlab.com/ce/api/lint.html
22func (s *ValidateService) Lint(content string, options ...OptionFunc) (*LintResult, *Response, error) {
23 var opts struct {
24 Content string `url:"content,omitempty" json:"content,omitempty"`
25 }
26 opts.Content = content
27
28 req, err := s.client.NewRequest("POST", "ci/lint", &opts, options)
29 if err != nil {
30 return nil, nil, err
31 }
32
33 l := new(LintResult)
34 resp, err := s.client.Do(req, l)
35 if err != nil {
36 return nil, resp, err
37 }
38
39 return l, resp, nil
40}