2018-11-05 08:45:36 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Gitlab
|
|
|
|
module Ci
|
|
|
|
module Parsers
|
|
|
|
ParserNotFoundError = Class.new(ParserError)
|
|
|
|
|
|
|
|
def self.parsers
|
|
|
|
{
|
2020-03-17 14:09:44 -04:00
|
|
|
junit: ::Gitlab::Ci::Parsers::Test::Junit,
|
2020-04-21 11:21:10 -04:00
|
|
|
cobertura: ::Gitlab::Ci::Parsers::Coverage::Cobertura,
|
2020-05-05 14:09:43 -04:00
|
|
|
terraform: ::Gitlab::Ci::Parsers::Terraform::Tfplan,
|
2020-11-23 10:09:37 -05:00
|
|
|
accessibility: ::Gitlab::Ci::Parsers::Accessibility::Pa11y,
|
2021-08-02 11:08:56 -04:00
|
|
|
codequality: ::Gitlab::Ci::Parsers::Codequality::CodeClimate,
|
|
|
|
sast: ::Gitlab::Ci::Parsers::Security::Sast,
|
|
|
|
secret_detection: ::Gitlab::Ci::Parsers::Security::SecretDetection
|
2018-11-05 08:45:36 -05:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2021-04-20 08:09:30 -04:00
|
|
|
def self.fabricate!(file_type, *args, **kwargs)
|
|
|
|
parsers.fetch(file_type.to_sym).new(*args, **kwargs)
|
2018-11-05 08:45:36 -05:00
|
|
|
rescue KeyError
|
|
|
|
raise ParserNotFoundError, "Cannot find any parser matching file type '#{file_type}'"
|
|
|
|
end
|
2021-01-22 16:09:10 -05:00
|
|
|
|
|
|
|
def self.instrument!
|
|
|
|
parsers.values.each { |parser_class| parser_class.prepend(Parsers::Instrumentation) }
|
|
|
|
end
|
2018-11-05 08:45:36 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2020-04-28 08:09:44 -04:00
|
|
|
|
2021-05-11 17:10:21 -04:00
|
|
|
Gitlab::Ci::Parsers.prepend_mod_with('Gitlab::Ci::Parsers')
|