2018-08-03 07:15:25 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-05-08 23:50:23 +00:00
|
|
|
module BlobViewer
|
|
|
|
class GitlabCiYml < Base
|
|
|
|
include ServerSide
|
|
|
|
include Auxiliary
|
|
|
|
|
|
|
|
self.partial_name = 'gitlab_ci_yml'
|
|
|
|
self.loading_partial_name = 'gitlab_ci_yml_loading'
|
2017-05-12 19:31:29 +00:00
|
|
|
self.file_types = %i(gitlab_ci)
|
2017-05-08 23:50:23 +00:00
|
|
|
self.binary = false
|
|
|
|
|
2018-12-01 11:39:13 +00:00
|
|
|
def validation_message(opts)
|
2017-05-08 23:50:23 +00:00
|
|
|
return @validation_message if defined?(@validation_message)
|
|
|
|
|
|
|
|
prepare!
|
|
|
|
|
2021-01-19 09:10:32 +00:00
|
|
|
@validation_message = Gitlab::Ci::Lint
|
|
|
|
.new(project: opts[:project], current_user: opts[:user], sha: opts[:sha])
|
|
|
|
.validate(blob.data).errors.first
|
2017-05-08 23:50:23 +00:00
|
|
|
end
|
|
|
|
|
2018-12-01 11:39:13 +00:00
|
|
|
def valid?(opts)
|
|
|
|
validation_message(opts).blank?
|
2017-05-08 23:50:23 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|