2018-12-05 23:21:45 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-09-29 09:46:39 +05:30
|
|
|
module API
|
2020-07-28 23:09:34 +05:30
|
|
|
class Lint < Grape::API::Instance
|
2016-09-29 09:46:39 +05:30
|
|
|
namespace :ci do
|
|
|
|
desc 'Validation of .gitlab-ci.yml content'
|
|
|
|
params do
|
|
|
|
requires :content, type: String, desc: 'Content of .gitlab-ci.yml'
|
|
|
|
end
|
|
|
|
post '/lint' do
|
2019-02-13 22:33:31 +05:30
|
|
|
error = Gitlab::Ci::YamlProcessor.validation_message(params[:content],
|
|
|
|
user: current_user)
|
2016-09-29 09:46:39 +05:30
|
|
|
|
|
|
|
status 200
|
|
|
|
|
|
|
|
if error.blank?
|
|
|
|
{ status: 'valid', errors: [] }
|
|
|
|
else
|
|
|
|
{ status: 'invalid', errors: [error] }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|