gitlab-org--gitlab-foss/lib/api/lint.rb

24 lines
530 B
Ruby
Raw Normal View History

# 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
error = Gitlab::Ci::YamlProcessor.validation_message(params[:content])
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