debian-mirror-gitlab/lib/gitlab/ci/pipeline/chain/config/content.rb

64 lines
1.9 KiB
Ruby
Raw Normal View History

2019-12-26 22:10:19 +05:30
# frozen_string_literal: true
module Gitlab
module Ci
module Pipeline
module Chain
module Config
class Content < Chain::Base
include Chain::Helpers
2020-01-01 13:55:28 +05:30
SOURCES = [
Gitlab::Ci::Pipeline::Chain::Config::Content::Runtime,
Gitlab::Ci::Pipeline::Chain::Config::Content::Repository,
Gitlab::Ci::Pipeline::Chain::Config::Content::ExternalProject,
Gitlab::Ci::Pipeline::Chain::Config::Content::Remote,
Gitlab::Ci::Pipeline::Chain::Config::Content::AutoDevops
].freeze
LEGACY_SOURCES = [
Gitlab::Ci::Pipeline::Chain::Config::Content::Runtime,
Gitlab::Ci::Pipeline::Chain::Config::Content::LegacyRepository,
Gitlab::Ci::Pipeline::Chain::Config::Content::LegacyAutoDevops
].freeze
2019-12-26 22:10:19 +05:30
2020-01-01 13:55:28 +05:30
def perform!
if config = find_config
# TODO: we should persist config_content
# @pipeline.config_content = config.content
@command.config_content = config.content
@pipeline.config_source = config.source
else
error('Missing CI config file')
2019-12-26 22:10:19 +05:30
end
end
def break?
@pipeline.errors.any? || @pipeline.persisted?
end
private
2020-01-01 13:55:28 +05:30
def find_config
sources.each do |source|
config = source.new(@pipeline, @command)
return config if config.exists?
end
2019-12-26 22:10:19 +05:30
nil
end
2020-01-01 13:55:28 +05:30
def sources
if Feature.enabled?(:ci_root_config_content, @command.project, default_enabled: true)
SOURCES
else
LEGACY_SOURCES
end
2019-12-26 22:10:19 +05:30
end
end
end
end
end
end
end