2019-07-07 11:18:12 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Gitlab
|
|
|
|
module Ci
|
|
|
|
class Config
|
|
|
|
module Entry
|
|
|
|
##
|
|
|
|
# Entry that represents a single include.
|
|
|
|
#
|
|
|
|
class Include < ::Gitlab::Config::Entry::Node
|
|
|
|
include ::Gitlab::Config::Entry::Validatable
|
2021-10-27 15:23:28 +05:30
|
|
|
include ::Gitlab::Config::Entry::Configurable
|
|
|
|
include ::Gitlab::Config::Entry::Attributable
|
2019-07-07 11:18:12 +05:30
|
|
|
|
2023-04-23 21:23:45 +05:30
|
|
|
ALLOWED_KEYS = %i[local file remote template component artifact job project ref rules].freeze
|
2019-07-07 11:18:12 +05:30
|
|
|
|
|
|
|
validations do
|
|
|
|
validates :config, hash_or_string: true
|
|
|
|
validates :config, allowed_keys: ALLOWED_KEYS
|
2020-04-22 19:07:51 +05:30
|
|
|
|
|
|
|
validate do
|
|
|
|
next unless config.is_a?(Hash)
|
|
|
|
|
|
|
|
if config[:artifact] && config[:job].blank?
|
|
|
|
errors.add(:config, "must specify the job where to fetch the artifact from")
|
|
|
|
end
|
2021-01-03 14:25:43 +05:30
|
|
|
|
|
|
|
if config[:project] && config[:file].blank?
|
|
|
|
errors.add(:config, "must specify the file where to fetch the config from")
|
|
|
|
end
|
2020-04-22 19:07:51 +05:30
|
|
|
end
|
2021-10-27 15:23:28 +05:30
|
|
|
|
|
|
|
with_options allow_nil: true do
|
|
|
|
validates :rules, array_of_hashes: true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
entry :rules, ::Gitlab::Ci::Config::Entry::Include::Rules,
|
2023-04-23 21:23:45 +05:30
|
|
|
description: 'List of evaluable Rules to determine file inclusion.',
|
|
|
|
inherit: false
|
2021-10-27 15:23:28 +05:30
|
|
|
|
|
|
|
attributes :rules
|
|
|
|
|
|
|
|
def skip_config_hash_validation?
|
|
|
|
true
|
2019-07-07 11:18:12 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|