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
7d8dd901
Commit
7d8dd901
authored
Jan 25, 2017
by
Gabriel Mazetto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added a proxy check and environment variables to info rake task
parent
9ba46172
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
0 deletions
+56
-0
lib/gitlab/proxy.rb
lib/gitlab/proxy.rb
+17
-0
lib/tasks/gitlab/info.rake
lib/tasks/gitlab/info.rake
+6
-0
spec/lib/gitlab/proxy_spec.rb
spec/lib/gitlab/proxy_spec.rb
+33
-0
No files found.
lib/gitlab/proxy.rb
0 → 100644
View file @
7d8dd901
module
Gitlab
class
Proxy
class
<<
self
# Try to detect possible proxies defined in the OS
# @return [Hash] of ENV variables that ends with '_proxy' case-insensitive
def
detect_proxy
env
.
select
{
|
k
,
v
|
/_proxy$/i
=~
k
}
end
private
def
env
ENV
end
end
end
end
lib/tasks/gitlab/info.rake
View file @
7d8dd901
...
@@ -15,10 +15,13 @@ namespace :gitlab do
...
@@ -15,10 +15,13 @@ namespace :gitlab do
rake_version
=
run_and_match
(
%W(rake --version)
,
/[\d\.]+/
).
try
(
:to_s
)
rake_version
=
run_and_match
(
%W(rake --version)
,
/[\d\.]+/
).
try
(
:to_s
)
# check redis version
# check redis version
redis_version
=
run_and_match
(
%W(redis-cli --version)
,
/redis-cli (\d+\.\d+\.\d+)/
).
to_a
redis_version
=
run_and_match
(
%W(redis-cli --version)
,
/redis-cli (\d+\.\d+\.\d+)/
).
to_a
# check for system defined proxies
proxies
=
Gitlab
::
Proxy
.
detect_proxy
.
map
{
|
k
,
v
|
"
#{
k
}
:
#{
v
}
"
}.
join
(
"
\n\t\t
"
)
puts
""
puts
""
puts
"System information"
.
color
(
:yellow
)
puts
"System information"
.
color
(
:yellow
)
puts
"System:
\t\t
#{
os_name
||
"unknown"
.
color
(
:red
)
}
"
puts
"System:
\t\t
#{
os_name
||
"unknown"
.
color
(
:red
)
}
"
puts
"Proxy:
\t\t
#{
proxies
.
present?
?
proxies
.
color
(
:green
)
:
"no"
}
"
puts
"Current User:
\t
#{
run_command
(
%W(whoami)
)
}
"
puts
"Current User:
\t
#{
run_command
(
%W(whoami)
)
}
"
puts
"Using RVM:
\t
#{
rvm_version
.
present?
?
"yes"
.
color
(
:green
)
:
"no"
}
"
puts
"Using RVM:
\t
#{
rvm_version
.
present?
?
"yes"
.
color
(
:green
)
:
"no"
}
"
puts
"RVM Version:
\t
#{
rvm_version
}
"
if
rvm_version
.
present?
puts
"RVM Version:
\t
#{
rvm_version
}
"
if
rvm_version
.
present?
...
@@ -84,6 +87,9 @@ namespace :gitlab do
...
@@ -84,6 +87,9 @@ namespace :gitlab do
puts
"Hooks:
\t\t
#{
Gitlab
.
config
.
gitlab_shell
.
hooks_path
}
"
puts
"Hooks:
\t\t
#{
Gitlab
.
config
.
gitlab_shell
.
hooks_path
}
"
puts
"Git:
\t\t
#{
Gitlab
.
config
.
git
.
bin_path
}
"
puts
"Git:
\t\t
#{
Gitlab
.
config
.
git
.
bin_path
}
"
puts
""
puts
"Environment Variables"
.
color
(
:yellow
)
puts
ENV
.
map
{
|
k
,
v
|
%Q(
#{
k
}
="
#{
v
}
")
}.
join
(
"
\n
"
)
end
end
end
end
end
end
spec/lib/gitlab/proxy_spec.rb
0 → 100644
View file @
7d8dd901
require
'spec_helper'
describe
Gitlab
::
Proxy
do
describe
'.detect_proxy'
do
subject
{
described_class
.
detect_proxy
}
context
'without any existing proxies'
do
before
do
allow
(
described_class
).
to
receive
(
:env
).
and_return
({})
end
it
'returns an empty array'
do
expect
(
subject
).
to
be_empty
end
end
context
'with existing proxies'
do
before
do
stubbed_env
=
{
'http_proxy'
=>
'http://proxy.example.com'
,
'HTTPS_PROXY'
=>
'https://proxy.example.com'
,
'http_notaproxy'
=>
'http://example.com'
}
allow
(
described_class
).
to
receive
(
:env
).
and_return
(
stubbed_env
)
end
it
'returns a list of existing proxies'
do
aggregate_failures
'list of proxies'
do
expect
(
subject
).
to
include
(
'http_proxy'
)
expect
(
subject
).
to
include
(
'HTTPS_PROXY'
)
expect
(
subject
).
not_to
include
(
'http_notaproxy'
)
end
end
end
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