2016-08-24 09:42:48 +00:00
|
|
|
module API
|
|
|
|
class Lint < Grape::API
|
2016-08-30 13:38:36 +00:00
|
|
|
namespace :ci do
|
2016-09-07 10:19:36 +00:00
|
|
|
desc 'Validation of .gitlab-ci.yml content'
|
|
|
|
params do
|
|
|
|
requires :content, type: String, desc: 'Content of .gitlab-ci.yml'
|
|
|
|
end
|
2016-08-30 11:03:29 +00:00
|
|
|
post '/lint' do
|
2016-08-31 09:16:25 +00:00
|
|
|
error = Ci::GitlabCiYamlProcessor.validation_message(params[:content])
|
2016-08-25 11:40:35 +00:00
|
|
|
|
2016-08-30 11:03:29 +00:00
|
|
|
status 200
|
2016-08-29 13:07:19 +00:00
|
|
|
|
2016-08-31 09:16:25 +00:00
|
|
|
if error.blank?
|
2016-08-30 11:03:29 +00:00
|
|
|
{ status: 'valid', errors: [] }
|
|
|
|
else
|
2016-08-31 09:16:25 +00:00
|
|
|
{ status: 'invalid', errors: [error] }
|
2016-08-30 11:03:29 +00:00
|
|
|
end
|
|
|
|
end
|
2016-08-24 09:42:48 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|