2018-09-29 18:34:47 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-08-24 05:42:48 -04:00
|
|
|
module API
|
|
|
|
class Lint < Grape::API
|
2016-08-30 09:38:36 -04:00
|
|
|
namespace :ci do
|
2016-09-07 06:19:36 -04:00
|
|
|
desc 'Validation of .gitlab-ci.yml content'
|
|
|
|
params do
|
|
|
|
requires :content, type: String, desc: 'Content of .gitlab-ci.yml'
|
|
|
|
end
|
2016-08-30 07:03:29 -04:00
|
|
|
post '/lint' do
|
2017-09-06 07:23:24 -04:00
|
|
|
error = Gitlab::Ci::YamlProcessor.validation_message(params[:content])
|
2016-08-25 07:40:35 -04:00
|
|
|
|
2016-08-30 07:03:29 -04:00
|
|
|
status 200
|
2016-08-29 09:07:19 -04:00
|
|
|
|
2016-08-31 05:16:25 -04:00
|
|
|
if error.blank?
|
2016-08-30 07:03:29 -04:00
|
|
|
{ status: 'valid', errors: [] }
|
|
|
|
else
|
2016-08-31 05:16:25 -04:00
|
|
|
{ status: 'invalid', errors: [error] }
|
2016-08-30 07:03:29 -04:00
|
|
|
end
|
|
|
|
end
|
2016-08-24 05:42:48 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|