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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
e0830a74
Commit
e0830a74
authored
Oct 18, 2018
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract method that fetchesremote CI/CD included config
parent
2243f0e3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
13 deletions
+12
-13
lib/gitlab/ci/config/external/file/remote.rb
lib/gitlab/ci/config/external/file/remote.rb
+9
-9
lib/gitlab/ci/config/external/processor.rb
lib/gitlab/ci/config/external/processor.rb
+1
-2
spec/lib/gitlab/ci/config/external/processor_spec.rb
spec/lib/gitlab/ci/config/external/processor_spec.rb
+2
-2
No files found.
lib/gitlab/ci/config/external/file/remote.rb
View file @
e0830a74
...
@@ -10,20 +10,20 @@ module Gitlab
...
@@ -10,20 +10,20 @@ module Gitlab
attr_reader
:location
attr_reader
:location
def
content
def
content
return
@content
if
defined?
(
@content
)
strong_memoize
(
:content
)
{
fetch_remote_content
}
@content
=
strong_memoize
(
:content
)
do
begin
Gitlab
::
HTTP
.
get
(
location
)
rescue
Gitlab
::
HTTP
::
Error
,
Timeout
::
Error
,
SocketError
,
Gitlab
::
HTTP
::
BlockedUrlError
nil
end
end
end
end
def
error_message
def
error_message
"Remote file '
#{
location
}
' is not valid."
"Remote file '
#{
location
}
' is not valid."
end
end
private
def
fetch_remote_content
Gitlab
::
HTTP
.
get
(
location
)
rescue
Gitlab
::
HTTP
::
Error
,
Timeout
::
Error
,
SocketError
,
Gitlab
::
HTTP
::
BlockedUrlError
nil
end
end
end
end
end
end
end
...
...
lib/gitlab/ci/config/external/processor.rb
View file @
e0830a74
...
@@ -6,7 +6,6 @@ module Gitlab
...
@@ -6,7 +6,6 @@ module Gitlab
module
External
module
External
class
Processor
class
Processor
IncludeError
=
Class
.
new
(
StandardError
)
IncludeError
=
Class
.
new
(
StandardError
)
FileError
=
Class
.
new
(
IncludeError
)
def
initialize
(
values
,
project
,
sha
)
def
initialize
(
values
,
project
,
sha
)
@values
=
values
@values
=
values
...
@@ -32,7 +31,7 @@ module Gitlab
...
@@ -32,7 +31,7 @@ module Gitlab
def
validate_external_file
(
external_file
)
def
validate_external_file
(
external_file
)
unless
external_file
.
valid?
unless
external_file
.
valid?
raise
Fil
eError
,
external_file
.
error_message
raise
Includ
eError
,
external_file
.
error_message
end
end
end
end
...
...
spec/lib/gitlab/ci/config/external/processor_spec.rb
View file @
e0830a74
...
@@ -20,7 +20,7 @@ describe Gitlab::Ci::Config::External::Processor do
...
@@ -20,7 +20,7 @@ describe Gitlab::Ci::Config::External::Processor do
it
'should raise an error'
do
it
'should raise an error'
do
expect
{
processor
.
perform
}.
to
raise_error
(
expect
{
processor
.
perform
}.
to
raise_error
(
described_class
::
Fil
eError
,
described_class
::
Includ
eError
,
"Local file '/lib/gitlab/ci/templates/non-existent-file.yml' is not valid."
"Local file '/lib/gitlab/ci/templates/non-existent-file.yml' is not valid."
)
)
end
end
...
@@ -36,7 +36,7 @@ describe Gitlab::Ci::Config::External::Processor do
...
@@ -36,7 +36,7 @@ describe Gitlab::Ci::Config::External::Processor do
it
'should raise an error'
do
it
'should raise an error'
do
expect
{
processor
.
perform
}.
to
raise_error
(
expect
{
processor
.
perform
}.
to
raise_error
(
described_class
::
Fil
eError
,
described_class
::
Includ
eError
,
"Remote file '
#{
remote_file
}
' is not valid."
"Remote file '
#{
remote_file
}
' is not valid."
)
)
end
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