1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package gitlab
18
19 import (
20 "fmt"
21 "net/http"
22 )
23
24
25
26
27
28 type ValidateService struct {
29 client *Client
30 }
31
32
33
34
35 type LintResult struct {
36 Status string `json:"status"`
37 Errors []string `json:"errors"`
38 Warnings []string `json:"warnings"`
39 MergedYaml string `json:"merged_yaml"`
40 }
41
42
43
44
45
46 type ProjectLintResult struct {
47 Valid bool `json:"valid"`
48 Errors []string `json:"errors"`
49 Warnings []string `json:"warnings"`
50 MergedYaml string `json:"merged_yaml"`
51 }
52
53
54
55
56
57 type LintOptions struct {
58 Content string `url:"content,omitempty" json:"content,omitempty"`
59 IncludeMergedYAML bool `url:"include_merged_yaml,omitempty" json:"include_merged_yaml,omitempty"`
60 IncludeJobs bool `url:"include_jobs,omitempty" json:"include_jobs,omitempty"`
61 }
62
63
64
65
66
67
68 func (s *ValidateService) Lint(opts *LintOptions, options ...RequestOptionFunc) (*LintResult, *Response, error) {
69 req, err := s.client.NewRequest(http.MethodPost, "ci/lint", &opts, options)
70 if err != nil {
71 return nil, nil, err
72 }
73
74 l := new(LintResult)
75 resp, err := s.client.Do(req, l)
76 if err != nil {
77 return nil, resp, err
78 }
79
80 return l, resp, nil
81 }
82
83
84
85
86
87 type ProjectNamespaceLintOptions struct {
88 Content *string `url:"content,omitempty" json:"content,omitempty"`
89 DryRun *bool `url:"dry_run,omitempty" json:"dry_run,omitempty"`
90 IncludeJobs *bool `url:"include_jobs,omitempty" json:"include_jobs,omitempty"`
91 Ref *string `url:"ref,omitempty" json:"ref,omitempty"`
92 }
93
94
95
96
97
98 func (s *ValidateService) ProjectNamespaceLint(pid interface{}, opt *ProjectNamespaceLintOptions, options ...RequestOptionFunc) (*ProjectLintResult, *Response, error) {
99 project, err := parseID(pid)
100 if err != nil {
101 return nil, nil, err
102 }
103 u := fmt.Sprintf("projects/%s/ci/lint", PathEscape(project))
104
105 req, err := s.client.NewRequest(http.MethodPost, u, &opt, options)
106 if err != nil {
107 return nil, nil, err
108 }
109
110 l := new(ProjectLintResult)
111 resp, err := s.client.Do(req, l)
112 if err != nil {
113 return nil, resp, err
114 }
115
116 return l, resp, nil
117 }
118
119
120
121
122
123 type ProjectLintOptions struct {
124 ContentRef *string `url:"content_ref,omitempty" json:"content_ref,omitempty"`
125 DryRunRef *string `url:"dry_run_ref,omitempty" json:"dry_run_ref,omitempty"`
126 DryRun *bool `url:"dry_run,omitempty" json:"dry_run,omitempty"`
127 IncludeJobs *bool `url:"include_jobs,omitempty" json:"include_jobs,omitempty"`
128 Ref *string `url:"ref,omitempty" json:"ref,omitempty"`
129 }
130
131
132
133
134
135 func (s *ValidateService) ProjectLint(pid interface{}, opt *ProjectLintOptions, options ...RequestOptionFunc) (*ProjectLintResult, *Response, error) {
136 project, err := parseID(pid)
137 if err != nil {
138 return nil, nil, err
139 }
140 u := fmt.Sprintf("projects/%s/ci/lint", PathEscape(project))
141
142 req, err := s.client.NewRequest(http.MethodGet, u, &opt, options)
143 if err != nil {
144 return nil, nil, err
145 }
146
147 l := new(ProjectLintResult)
148 resp, err := s.client.Do(req, l)
149 if err != nil {
150 return nil, resp, err
151 }
152
153 return l, resp, nil
154 }
155
View as plain text