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
Jérome Perrin
gitlab-ce
Commits
bf25b5f6
Commit
bf25b5f6
authored
Nov 18, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove CI config helper with same name as an entry
parent
65724301
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
64 additions
and
37 deletions
+64
-37
lib/gitlab/ci/config.rb
lib/gitlab/ci/config.rb
+35
-6
lib/gitlab/ci/config/entry/configurable.rb
lib/gitlab/ci/config/entry/configurable.rb
+0
-2
spec/lib/gitlab/ci/config/entry/global_spec.rb
spec/lib/gitlab/ci/config/entry/global_spec.rb
+29
-29
No files found.
lib/gitlab/ci/config.rb
View file @
bf25b5f6
...
@@ -4,12 +4,6 @@ module Gitlab
...
@@ -4,12 +4,6 @@ module Gitlab
# Base GitLab CI Configuration facade
# Base GitLab CI Configuration facade
#
#
class
Config
class
Config
##
# Temporary delegations that should be removed after refactoring
#
delegate
:before_script
,
:image
,
:services
,
:after_script
,
:variables
,
:stages
,
:cache
,
:jobs
,
to: :@global
def
initialize
(
config
)
def
initialize
(
config
)
@config
=
Loader
.
new
(
config
).
load!
@config
=
Loader
.
new
(
config
).
load!
...
@@ -28,6 +22,41 @@ module Gitlab
...
@@ -28,6 +22,41 @@ module Gitlab
def
to_hash
def
to_hash
@config
@config
end
end
##
# Temporary method that should be removed after refactoring
#
def
before_script
@global
.
before_script_value
end
def
image
@global
.
image_value
end
def
services
@global
.
services_value
end
def
after_script
@global
.
after_script_value
end
def
variables
@global
.
variables_value
end
def
stages
@global
.
stages_value
end
def
cache
@global
.
cache_value
end
def
jobs
@global
.
jobs_value
end
end
end
end
end
end
end
lib/gitlab/ci/config/entry/configurable.rb
View file @
bf25b5f6
...
@@ -66,8 +66,6 @@ module Gitlab
...
@@ -66,8 +66,6 @@ module Gitlab
@entries
[
symbol
].
value
@entries
[
symbol
].
value
end
end
alias_method
symbol
.
to_sym
,
"
#{
symbol
}
_value"
.
to_sym
end
end
end
end
end
end
...
...
spec/lib/gitlab/ci/config/entry/global_spec.rb
View file @
bf25b5f6
...
@@ -60,9 +60,9 @@ describe Gitlab::Ci::Config::Entry::Global do
...
@@ -60,9 +60,9 @@ describe Gitlab::Ci::Config::Entry::Global do
end
end
context
'when not composed'
do
context
'when not composed'
do
describe
'#before_script'
do
describe
'#before_script
_value
'
do
it
'returns nil'
do
it
'returns nil'
do
expect
(
global
.
before_script
).
to
be
nil
expect
(
global
.
before_script
_value
).
to
be
nil
end
end
end
end
...
@@ -82,40 +82,40 @@ describe Gitlab::Ci::Config::Entry::Global do
...
@@ -82,40 +82,40 @@ describe Gitlab::Ci::Config::Entry::Global do
end
end
end
end
describe
'#before_script'
do
describe
'#before_script
_value
'
do
it
'returns correct script'
do
it
'returns correct script'
do
expect
(
global
.
before_script
).
to
eq
[
'ls'
,
'pwd'
]
expect
(
global
.
before_script
_value
).
to
eq
[
'ls'
,
'pwd'
]
end
end
end
end
describe
'#image'
do
describe
'#image
_value
'
do
it
'returns valid image'
do
it
'returns valid image'
do
expect
(
global
.
image
).
to
eq
'ruby:2.2'
expect
(
global
.
image
_value
).
to
eq
'ruby:2.2'
end
end
end
end
describe
'#services'
do
describe
'#services
_value
'
do
it
'returns array of services'
do
it
'returns array of services'
do
expect
(
global
.
services
).
to
eq
[
'postgres:9.1'
,
'mysql:5.5'
]
expect
(
global
.
services
_value
).
to
eq
[
'postgres:9.1'
,
'mysql:5.5'
]
end
end
end
end
describe
'#after_script'
do
describe
'#after_script
_value
'
do
it
'returns after script'
do
it
'returns after script'
do
expect
(
global
.
after_script
).
to
eq
[
'make clean'
]
expect
(
global
.
after_script
_value
).
to
eq
[
'make clean'
]
end
end
end
end
describe
'#variables'
do
describe
'#variables
_value
'
do
it
'returns variables'
do
it
'returns variables'
do
expect
(
global
.
variables
).
to
eq
(
VAR
:
'value'
)
expect
(
global
.
variables
_value
).
to
eq
(
VAR
:
'value'
)
end
end
end
end
describe
'#stages'
do
describe
'#stages
_value
'
do
context
'when stages key defined'
do
context
'when stages key defined'
do
it
'returns array of stages'
do
it
'returns array of stages'
do
expect
(
global
.
stages
).
to
eq
%w[build pages]
expect
(
global
.
stages
_value
).
to
eq
%w[build pages]
end
end
end
end
...
@@ -126,21 +126,21 @@ describe Gitlab::Ci::Config::Entry::Global do
...
@@ -126,21 +126,21 @@ describe Gitlab::Ci::Config::Entry::Global do
end
end
it
'returns array of types as stages'
do
it
'returns array of types as stages'
do
expect
(
global
.
stages
).
to
eq
%w[test deploy]
expect
(
global
.
stages
_value
).
to
eq
%w[test deploy]
end
end
end
end
end
end
describe
'#cache'
do
describe
'#cache
_value
'
do
it
'returns cache configuration'
do
it
'returns cache configuration'
do
expect
(
global
.
cache
)
expect
(
global
.
cache
_value
)
.
to
eq
(
key:
'k'
,
untracked:
true
,
paths:
[
'public/'
])
.
to
eq
(
key:
'k'
,
untracked:
true
,
paths:
[
'public/'
])
end
end
end
end
describe
'#jobs'
do
describe
'#jobs
_value
'
do
it
'returns jobs configuration'
do
it
'returns jobs configuration'
do
expect
(
global
.
jobs
).
to
eq
(
expect
(
global
.
jobs
_value
).
to
eq
(
rspec:
{
name: :rspec
,
rspec:
{
name: :rspec
,
script:
%w[rspec ls]
,
script:
%w[rspec ls]
,
before_script:
[
'ls'
,
'pwd'
],
before_script:
[
'ls'
,
'pwd'
],
...
@@ -185,21 +185,21 @@ describe Gitlab::Ci::Config::Entry::Global do
...
@@ -185,21 +185,21 @@ describe Gitlab::Ci::Config::Entry::Global do
end
end
end
end
describe
'#variables'
do
describe
'#variables
_value
'
do
it
'returns default value for variables'
do
it
'returns default value for variables'
do
expect
(
global
.
variables
).
to
eq
({})
expect
(
global
.
variables
_value
).
to
eq
({})
end
end
end
end
describe
'#stages'
do
describe
'#stages
_value
'
do
it
'returns an array of default stages'
do
it
'returns an array of default stages'
do
expect
(
global
.
stages
).
to
eq
%w[build test deploy]
expect
(
global
.
stages
_value
).
to
eq
%w[build test deploy]
end
end
end
end
describe
'#cache'
do
describe
'#cache
_value
'
do
it
'returns correct cache definition'
do
it
'returns correct cache definition'
do
expect
(
global
.
cache
).
to
eq
(
key:
'a'
)
expect
(
global
.
cache
_value
).
to
eq
(
key:
'a'
)
end
end
end
end
end
end
...
@@ -217,9 +217,9 @@ describe Gitlab::Ci::Config::Entry::Global do
...
@@ -217,9 +217,9 @@ describe Gitlab::Ci::Config::Entry::Global do
{
variables:
nil
,
rspec:
{
script:
'rspec'
}
}
{
variables:
nil
,
rspec:
{
script:
'rspec'
}
}
end
end
describe
'#variables'
do
describe
'#variables
_value
'
do
it
'undefined entry returns a default value'
do
it
'undefined entry returns a default value'
do
expect
(
global
.
variables
).
to
eq
({})
expect
(
global
.
variables
_value
).
to
eq
({})
end
end
end
end
end
end
...
@@ -245,9 +245,9 @@ describe Gitlab::Ci::Config::Entry::Global do
...
@@ -245,9 +245,9 @@ describe Gitlab::Ci::Config::Entry::Global do
end
end
end
end
describe
'#before_script'
do
describe
'#before_script
_value
'
do
it
'returns nil'
do
it
'returns nil'
do
expect
(
global
.
before_script
).
to
be_nil
expect
(
global
.
before_script
_value
).
to
be_nil
end
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