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:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-10-19 15:57:54 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-10-19 15:57:54 +0300
commit419c53ec62de6e97a517abd5fdd4cbde3a942a34 (patch)
tree1f43a548b46bca8a5fb8fe0c31cef1883d49c5b6 /lib/gitlab/ci/config/interpolation/context.rb
parent1da20d9135b3ad9e75e65b028bffc921aaf8deb7 (diff)
Add latest changes from gitlab-org/gitlab@16-5-stable-eev16.5.0-rc42
Diffstat (limited to 'lib/gitlab/ci/config/interpolation/context.rb')
-rw-r--r--lib/gitlab/ci/config/interpolation/context.rb23
1 files changed, 13 insertions, 10 deletions
diff --git a/lib/gitlab/ci/config/interpolation/context.rb b/lib/gitlab/ci/config/interpolation/context.rb
index f5e7db03291..19ea619f7da 100644
--- a/lib/gitlab/ci/config/interpolation/context.rb
+++ b/lib/gitlab/ci/config/interpolation/context.rb
@@ -14,8 +14,11 @@ module Gitlab
MAX_DEPTH = 3
- def initialize(hash)
- @context = hash
+ attr_reader :variables
+
+ def initialize(data, variables: [])
+ @data = data
+ @variables = Ci::Variables::Collection.fabricate(variables)
raise ContextTooComplexError if depth > MAX_DEPTH
end
@@ -32,25 +35,25 @@ module Gitlab
end
def depth
- deep_depth(@context)
+ deep_depth(@data)
end
def fetch(field)
- @context.fetch(field)
+ @data.fetch(field)
end
def key?(name)
- @context.key?(name)
+ @data.key?(name)
end
def to_h
- @context.to_h
+ @data.to_h
end
private
- def deep_depth(context, depth = 0)
- values = context.values.map do |value|
+ def deep_depth(data, depth = 0)
+ values = data.values.map do |value|
if value.is_a?(Hash)
deep_depth(value, depth + 1)
else
@@ -61,10 +64,10 @@ module Gitlab
values.max.to_i
end
- def self.fabricate(context)
+ def self.fabricate(context, variables: [])
case context
when Hash
- new(context)
+ new(context, variables: variables)
when Interpolation::Context
context
else