diff options
author | Katarzyna Kobierska <kkobierska@gmail.com> | 2016-08-24 11:42:48 +0200 |
---|---|---|
committer | Katarzyna Kobierska <kkobierska@gmail.com> | 2016-09-07 12:10:49 +0200 |
commit | ca1f5ede8456b0c433699fc73931ad39b5571f97 (patch) | |
tree | 56d259f58ca04cd1efd37bd7ec5b60adeb83cb65 /lib/api | |
parent | 257c2acde7a0be63d955df63ca29488236e5654f (diff) | |
download | gitlab-ce-ca1f5ede8456b0c433699fc73931ad39b5571f97.tar.gz |
Move lint to api from ci/api
Diffstat (limited to 'lib/api')
-rw-r--r-- | lib/api/api.rb | 1 | ||||
-rw-r--r-- | lib/api/lint.rb | 38 |
2 files changed, 39 insertions, 0 deletions
diff --git a/lib/api/api.rb b/lib/api/api.rb index e14464c1b0d..a08fb056049 100644 --- a/lib/api/api.rb +++ b/lib/api/api.rb @@ -45,6 +45,7 @@ module API mount ::API::Keys mount ::API::Labels mount ::API::LicenseTemplates + mount ::API::Lint mount ::API::Members mount ::API::MergeRequests mount ::API::Milestones diff --git a/lib/api/lint.rb b/lib/api/lint.rb new file mode 100644 index 00000000000..68eabb571d6 --- /dev/null +++ b/lib/api/lint.rb @@ -0,0 +1,38 @@ +module API + class Lint < Grape::API + resource :lint do + params do + requires :content, type: String, desc: 'content of .gitlab-ci.yml' + end + + desc 'Validation of .gitlab-ci.yml content' + post do + status 200 + + begin + response = { + status: '', + errors: [], + jobs: [] + } + + config_processor = Ci::GitlabCiYamlProcessor.new(params[:content]) + + config_processor.builds.each do |build| + response[:jobs].push("#{build[:name]}") + response[:status] = 'valid' + end + + response + + rescue Ci::GitlabCiYamlProcessor::ValidationError, Psych::SyntaxError => e + status 200 + response[:errors].push(e.message) + response[:status] = 'invalid' + + response + end + end + end + end +end |