validate.go 993 B

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