Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/ci/config/external/rules.rb')
-rw-r--r--lib/gitlab/ci/config/external/rules.rb20
1 files changed, 18 insertions, 2 deletions
diff --git a/lib/gitlab/ci/config/external/rules.rb b/lib/gitlab/ci/config/external/rules.rb
index 59e666b8bb5..0e6209460e0 100644
--- a/lib/gitlab/ci/config/external/rules.rb
+++ b/lib/gitlab/ci/config/external/rules.rb
@@ -5,15 +5,29 @@ module Gitlab
class Config
module External
class Rules
+ # Remove these two constants when FF `ci_refactor_external_rules` is removed
ALLOWED_KEYS = Entry::Include::Rules::Rule::ALLOWED_KEYS
ALLOWED_WHEN = Entry::Include::Rules::Rule::ALLOWED_WHEN
InvalidIncludeRulesError = Class.new(Mapper::Error)
def initialize(rule_hashes)
- validate(rule_hashes)
+ if Feature.enabled?(:ci_refactor_external_rules)
+ return unless rule_hashes
- @rule_list = Build::Rules::Rule.fabricate_list(rule_hashes)
+ # We must compose the include rules entry here because included
+ # files are expanded before `@root.compose!` runs in Ci::Config.
+ rules_entry = Entry::Include::Rules.new(rule_hashes)
+ rules_entry.compose!
+
+ raise InvalidIncludeRulesError, "include:#{rules_entry.errors.first}" unless rules_entry.valid?
+
+ @rule_list = Build::Rules::Rule.fabricate_list(rules_entry.value)
+ else
+ validate(rule_hashes)
+
+ @rule_list = Build::Rules::Rule.fabricate_list(rule_hashes)
+ end
end
def evaluate(context)
@@ -32,6 +46,7 @@ module Gitlab
@rule_list.find { |rule| rule.matches?(nil, context) }
end
+ # Remove this method when FF `ci_refactor_external_rules` is removed
def validate(rule_hashes)
return unless rule_hashes.is_a?(Array)
@@ -42,6 +57,7 @@ module Gitlab
end
end
+ # Remove this method when FF `ci_refactor_external_rules` is removed
def valid_when?(rule_hash)
rule_hash[:when].nil? || rule_hash[:when].in?(ALLOWED_WHEN)
end