Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
d565ff04
Commit
d565ff04
authored
Mar 04, 2021
by
Pedro Pombeiro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make expand_variables_collection return Collection
parent
f4f66ddb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
2 deletions
+12
-2
lib/expand_variables.rb
lib/expand_variables.rb
+4
-2
spec/lib/expand_variables_spec.rb
spec/lib/expand_variables_spec.rb
+8
-0
No files found.
lib/expand_variables.rb
View file @
d565ff04
...
...
@@ -19,7 +19,8 @@ module ExpandVariables
# expand_variables_collection expands a Gitlab::Ci::Variables::Collection, ignoring unknown variable references.
# If a circular variable reference is found, the original Collection is returned
def
expand_variables_collection
(
variables
,
project
)
return
variables
if
Feature
.
disabled?
(
:variable_inside_variable
,
project
)
return
Gitlab
::
Ci
::
Variables
::
Collection
.
new
(
variables
)
if
Feature
.
disabled?
(
:variable_inside_variable
,
project
)
sorted_variables
=
variables
.
sorted_collection
(
project
)
return
sorted_variables
if
sorted_variables
.
errors
...
...
@@ -77,10 +78,11 @@ module ExpandVariables
def
expand_sorted_variables_collection
(
sorted_variables
)
expanded_vars
=
{}
sorted_variables
.
map
do
|
item
|
sorted_variables
.
each_with_object
(
Gitlab
::
Ci
::
Variables
::
Collection
.
new
)
do
|
item
,
collection
|
item
=
item
.
merge
(
value:
expand_existing
(
item
.
value
,
expanded_vars
))
if
item
.
depends_on
expanded_vars
.
store
(
item
[
:key
],
item
)
collection
.
append
(
item
)
end
end
end
...
...
spec/lib/expand_variables_spec.rb
View file @
d565ff04
...
...
@@ -325,6 +325,10 @@ RSpec.describe ExpandVariables do
with_them
do
subject
{
ExpandVariables
.
expand_variables_collection
(
variables
,
project_with_flag_disabled
)
}
it
'returns Collection'
do
is_expected
.
to
be_an_instance_of
(
Gitlab
::
Ci
::
Variables
::
Collection
)
end
it
'does not expand variables'
do
is_expected
.
to
eq
(
variables
)
end
...
...
@@ -477,6 +481,10 @@ RSpec.describe ExpandVariables do
ExpandVariables
.
expand_variables_collection
(
collection
,
project_with_flag_enabled
)
end
it
'returns Collection'
do
is_expected
.
to
be_an_instance_of
(
Gitlab
::
Ci
::
Variables
::
Collection
)
end
it
'expands variables'
do
is_expected
.
to
eq
(
result
)
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment