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
4c12f02f
Commit
4c12f02f
authored
Dec 24, 2020
by
Aishwarya Subramanian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Checks for data type before expansion
Expand variable only if its of the type String
parent
9ffb0985
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
2 deletions
+26
-2
lib/gitlab/ci/config/external/mapper.rb
lib/gitlab/ci/config/external/mapper.rb
+13
-2
spec/lib/gitlab/ci/config/external/mapper_spec.rb
spec/lib/gitlab/ci/config/external/mapper_spec.rb
+13
-0
No files found.
lib/gitlab/ci/config/external/mapper.rb
View file @
4c12f02f
...
@@ -105,8 +105,19 @@ module Gitlab
...
@@ -105,8 +105,19 @@ module Gitlab
if
data
.
is_a?
(
String
)
if
data
.
is_a?
(
String
)
expand
(
data
)
expand
(
data
)
else
else
data
.
transform_values
do
|
values
|
transform
(
data
)
values
.
is_a?
(
Array
)
?
values
.
map
{
|
value
|
expand
(
value
)
}
:
expand
(
values
)
end
end
def
transform
(
data
)
data
.
transform_values
do
|
values
|
case
values
when
Array
values
.
map
{
|
value
|
expand
(
value
.
to_s
)
}
when
String
expand
(
values
)
else
values
end
end
end
end
end
end
...
...
spec/lib/gitlab/ci/config/external/mapper_spec.rb
View file @
4c12f02f
...
@@ -322,6 +322,19 @@ RSpec.describe Gitlab::Ci::Config::External::Mapper do
...
@@ -322,6 +322,19 @@ RSpec.describe Gitlab::Ci::Config::External::Mapper do
end
end
end
end
context
'when include variable has an unsupported type for variable expansion'
do
let
(
:values
)
do
{
include:
{
project:
project
.
id
,
file:
local_file
},
image:
'ruby:2.7'
}
end
it
'does not invoke expansion for the variable'
,
:aggregate_failures
do
expect
(
ExpandVariables
).
not_to
receive
(
:expand
).
with
(
project
.
id
,
context_params
[
:variables
])
expect
{
subject
}.
to
raise_error
(
described_class
::
AmbigiousSpecificationError
)
end
end
context
'when feature flag is turned off'
do
context
'when feature flag is turned off'
do
let
(
:values
)
do
let
(
:values
)
do
{
include:
full_local_file_path
}
{
include:
full_local_file_path
}
...
...
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