blob: c13baaea8c6dd051b2e69ab2c939166e7b430315 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# frozen_string_literal: true
class Projects::Ci::LintsController < Projects::ApplicationController
before_action :authorize_create_pipeline!
def show
end
def create
@content = params[:content]
@dry_run = params[:dry_run]
if @dry_run && Gitlab::Ci::Features.lint_creates_pipeline_with_dry_run?(@project)
pipeline = Ci::CreatePipelineService
.new(@project, current_user, ref: @project.default_branch)
.execute(:push, dry_run: true, content: @content)
@status = pipeline.error_messages.empty?
@stages = pipeline.stages
@errors = pipeline.error_messages.map(&:content)
@warnings = pipeline.warning_messages.map(&:content)
else
result = Gitlab::Ci::YamlProcessor.new_with_validation_errors(@content, yaml_processor_options)
@status = result.valid?
@errors = result.errors
@warnings = result.warnings
if result.valid?
@config_processor = result.config
@stages = @config_processor.stages
@builds = @config_processor.builds
@jobs = @config_processor.jobs
end
end
render :show
end
private
def yaml_processor_options
{
project: @project,
user: current_user,
sha: project.repository.commit.sha
}
end
end
|