Commit 4eb665dd authored by drew cimino's avatar drew cimino

Ci::YamlProcessor#validation_errors method for structured output

- Added a new method to return a list of errors instead of a single
  error string.
- Added simple join of structured error messages in Ci::LintsController
- Repeats some processing, but to avoid this would require refactoring
  exception raising and rescuing out of the entire class and all of its
  invocations across the application.
- Existing echnical debt issue addresses the overall problem:
  https://gitlab.com/gitlab-org/gitlab/issues/30066
parent a2aee704
......@@ -8,7 +8,7 @@ class Projects::Ci::LintsController < Projects::ApplicationController
def create
@content = params[:content]
@error = Gitlab::Ci::YamlProcessor.validation_message(@content, yaml_processor_options)
@error = Gitlab::Ci::YamlProcessor.validation_errors(@content, yaml_processor_options).join(', ')
@status = @error.blank?
if @error.blank?
......
......@@ -102,6 +102,20 @@ module Gitlab
end
end
def self.validation_errors(content, opts = {})
return ['Please provide content of .gitlab-ci.yml'] if content.blank?
config = Gitlab::Ci::Config.new(content, **opts)
return config.errors unless config.valid?
begin
Gitlab::Ci::YamlProcessor.new(content, opts)
[]
rescue ValidationError => e
[e.message]
end
end
private
def initial_parsing
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment