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
e6e812e2
Commit
e6e812e2
authored
Mar 04, 2020
by
Fabio Pitino
Committed by
Kamil Trzciński
Mar 04, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove `Configurable#helpers` method
Simplify configurations by defining helpers by default
parent
8da519a8
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
43 additions
and
30 deletions
+43
-30
ee/lib/gitlab/web_ide/config/entry/global.rb
ee/lib/gitlab/web_ide/config/entry/global.rb
+0
-2
ee/lib/gitlab/web_ide/config/entry/terminal.rb
ee/lib/gitlab/web_ide/config/entry/terminal.rb
+0
-2
lib/gitlab/ci/config/entry/artifacts.rb
lib/gitlab/ci/config/entry/artifacts.rb
+0
-2
lib/gitlab/ci/config/entry/bridge.rb
lib/gitlab/ci/config/entry/bridge.rb
+0
-2
lib/gitlab/ci/config/entry/cache.rb
lib/gitlab/ci/config/entry/cache.rb
+0
-2
lib/gitlab/ci/config/entry/default.rb
lib/gitlab/ci/config/entry/default.rb
+0
-2
lib/gitlab/ci/config/entry/job.rb
lib/gitlab/ci/config/entry/job.rb
+0
-5
lib/gitlab/ci/config/entry/processable.rb
lib/gitlab/ci/config/entry/processable.rb
+0
-2
lib/gitlab/ci/config/entry/release.rb
lib/gitlab/ci/config/entry/release.rb
+0
-2
lib/gitlab/ci/config/entry/release/assets.rb
lib/gitlab/ci/config/entry/release/assets.rb
+0
-2
lib/gitlab/ci/config/entry/root.rb
lib/gitlab/ci/config/entry/root.rb
+1
-3
lib/gitlab/ci/config/entry/service.rb
lib/gitlab/ci/config/entry/service.rb
+32
-2
lib/gitlab/config/entry/configurable.rb
lib/gitlab/config/entry/configurable.rb
+10
-2
No files found.
ee/lib/gitlab/web_ide/config/entry/global.rb
View file @
e6e812e2
...
@@ -21,8 +21,6 @@ module Gitlab
...
@@ -21,8 +21,6 @@ module Gitlab
entry
:terminal
,
Entry
::
Terminal
,
entry
:terminal
,
Entry
::
Terminal
,
description:
'Configuration of the webide terminal.'
description:
'Configuration of the webide terminal.'
helpers
:terminal
attributes
:terminal
attributes
:terminal
end
end
end
end
...
...
ee/lib/gitlab/web_ide/config/entry/terminal.rb
View file @
e6e812e2
...
@@ -42,8 +42,6 @@ module Gitlab
...
@@ -42,8 +42,6 @@ module Gitlab
entry
:variables
,
::
Gitlab
::
Ci
::
Config
::
Entry
::
Variables
,
entry
:variables
,
::
Gitlab
::
Ci
::
Config
::
Entry
::
Variables
,
description:
'Environment variables available for this job.'
description:
'Environment variables available for this job.'
helpers
:before_script
,
:script
,
:image
,
:variables
,
:services
attributes
:tags
attributes
:tags
def
value
def
value
...
...
lib/gitlab/ci/config/entry/artifacts.rb
View file @
e6e812e2
...
@@ -44,8 +44,6 @@ module Gitlab
...
@@ -44,8 +44,6 @@ module Gitlab
end
end
end
end
helpers
:reports
def
value
def
value
@config
[
:reports
]
=
reports_value
if
@config
.
key?
(
:reports
)
@config
[
:reports
]
=
reports_value
if
@config
.
key?
(
:reports
)
@config
@config
...
...
lib/gitlab/ci/config/entry/bridge.rb
View file @
e6e812e2
...
@@ -49,8 +49,6 @@ module Gitlab
...
@@ -49,8 +49,6 @@ module Gitlab
description:
'Environment variables available for this job.'
,
description:
'Environment variables available for this job.'
,
inherit:
false
inherit:
false
helpers
:trigger
,
:needs
,
:variables
attributes
:when
,
:allow_failure
attributes
:when
,
:allow_failure
def
self
.
matching?
(
name
,
config
)
def
self
.
matching?
(
name
,
config
)
...
...
lib/gitlab/ci/config/entry/cache.rb
View file @
e6e812e2
...
@@ -28,8 +28,6 @@ module Gitlab
...
@@ -28,8 +28,6 @@ module Gitlab
entry
:paths
,
Entry
::
Paths
,
entry
:paths
,
Entry
::
Paths
,
description:
'Specify which paths should be cached across builds.'
description:
'Specify which paths should be cached across builds.'
helpers
:key
attributes
:policy
attributes
:policy
def
value
def
value
...
...
lib/gitlab/ci/config/entry/default.rb
View file @
e6e812e2
...
@@ -61,8 +61,6 @@ module Gitlab
...
@@ -61,8 +61,6 @@ module Gitlab
description:
'Default artifacts.'
,
description:
'Default artifacts.'
,
inherit:
false
inherit:
false
helpers
:before_script
,
:image
,
:services
,
:after_script
,
:cache
private
private
def
overwrite_entry
(
deps
,
key
,
current_entry
)
def
overwrite_entry
(
deps
,
key
,
current_entry
)
...
...
lib/gitlab/ci/config/entry/job.rb
View file @
e6e812e2
...
@@ -128,11 +128,6 @@ module Gitlab
...
@@ -128,11 +128,6 @@ module Gitlab
description:
'This job will produce a release.'
,
description:
'This job will produce a release.'
,
inherit:
false
inherit:
false
helpers
:before_script
,
:script
,
:type
,
:after_script
,
:cache
,
:image
,
:services
,
:variables
,
:artifacts
,
:environment
,
:coverage
,
:retry
,
:needs
,
:interruptible
,
:release
,
:tags
attributes
:script
,
:tags
,
:allow_failure
,
:when
,
:dependencies
,
attributes
:script
,
:tags
,
:allow_failure
,
:when
,
:dependencies
,
:needs
,
:retry
,
:parallel
,
:start_in
,
:needs
,
:retry
,
:parallel
,
:start_in
,
:interruptible
,
:timeout
,
:resource_group
,
:release
:interruptible
,
:timeout
,
:resource_group
,
:release
...
...
lib/gitlab/ci/config/entry/processable.rb
View file @
e6e812e2
...
@@ -54,8 +54,6 @@ module Gitlab
...
@@ -54,8 +54,6 @@ module Gitlab
allowed_when:
%w[on_success on_failure always never manual delayed]
.
freeze
allowed_when:
%w[on_success on_failure always never manual delayed]
.
freeze
}
}
helpers
:stage
,
:only
,
:except
,
:rules
attributes
:extends
,
:rules
attributes
:extends
,
:rules
end
end
...
...
lib/gitlab/ci/config/entry/release.rb
View file @
e6e812e2
...
@@ -33,8 +33,6 @@ module Gitlab
...
@@ -33,8 +33,6 @@ module Gitlab
validates
:description
,
type:
String
,
presence:
true
validates
:description
,
type:
String
,
presence:
true
end
end
helpers
:assets
def
value
def
value
@config
[
:assets
]
=
assets_value
if
@config
.
key?
(
:assets
)
@config
[
:assets
]
=
assets_value
if
@config
.
key?
(
:assets
)
@config
@config
...
...
lib/gitlab/ci/config/entry/release/assets.rb
View file @
e6e812e2
...
@@ -23,8 +23,6 @@ module Gitlab
...
@@ -23,8 +23,6 @@ module Gitlab
validates
:links
,
array_of_hashes:
true
,
presence:
true
validates
:links
,
array_of_hashes:
true
,
presence:
true
end
end
helpers
:links
def
value
def
value
@config
[
:links
]
=
links_value
if
@config
.
key?
(
:links
)
@config
[
:links
]
=
links_value
if
@config
.
key?
(
:links
)
@config
@config
...
...
lib/gitlab/ci/config/entry/root.rb
View file @
e6e812e2
...
@@ -67,9 +67,7 @@ module Gitlab
...
@@ -67,9 +67,7 @@ module Gitlab
entry
:workflow
,
Entry
::
Workflow
,
entry
:workflow
,
Entry
::
Workflow
,
description:
'List of evaluable rules to determine Pipeline status'
description:
'List of evaluable rules to determine Pipeline status'
helpers
:default
,
:stages
,
:types
,
:variables
,
:workflow
dynamic_helpers
:jobs
helpers
:jobs
,
dynamic:
true
delegate
:before_script_value
,
delegate
:before_script_value
,
:image_value
,
:image_value
,
...
...
lib/gitlab/ci/config/entry/service.rb
View file @
e6e812e2
...
@@ -7,8 +7,13 @@ module Gitlab
...
@@ -7,8 +7,13 @@ module Gitlab
##
##
# Entry that represents a configuration of Docker service.
# Entry that represents a configuration of Docker service.
#
#
class
Service
<
Image
# TODO: remove duplication with Image superclass by defining a common
# Imageable concern.
# https://gitlab.com/gitlab-org/gitlab/issues/208774
class
Service
<
::
Gitlab
::
Config
::
Entry
::
Node
include
::
Gitlab
::
Config
::
Entry
::
Validatable
include
::
Gitlab
::
Config
::
Entry
::
Validatable
include
::
Gitlab
::
Config
::
Entry
::
Attributable
include
::
Gitlab
::
Config
::
Entry
::
Configurable
ALLOWED_KEYS
=
%i[name entrypoint command alias ports]
.
freeze
ALLOWED_KEYS
=
%i[name entrypoint command alias ports]
.
freeze
...
@@ -16,9 +21,9 @@ module Gitlab
...
@@ -16,9 +21,9 @@ module Gitlab
validates
:config
,
hash_or_string:
true
validates
:config
,
hash_or_string:
true
validates
:config
,
allowed_keys:
ALLOWED_KEYS
validates
:config
,
allowed_keys:
ALLOWED_KEYS
validates
:config
,
disallowed_keys:
%i[ports]
,
unless: :with_image_ports?
validates
:config
,
disallowed_keys:
%i[ports]
,
unless: :with_image_ports?
validates
:name
,
type:
String
,
presence:
true
validates
:name
,
type:
String
,
presence:
true
validates
:entrypoint
,
array_of_strings:
true
,
allow_nil:
true
validates
:entrypoint
,
array_of_strings:
true
,
allow_nil:
true
validates
:command
,
array_of_strings:
true
,
allow_nil:
true
validates
:command
,
array_of_strings:
true
,
allow_nil:
true
validates
:alias
,
type:
String
,
allow_nil:
true
validates
:alias
,
type:
String
,
allow_nil:
true
validates
:alias
,
type:
String
,
presence:
true
,
unless:
->
(
record
)
{
record
.
ports
.
blank?
}
validates
:alias
,
type:
String
,
presence:
true
,
unless:
->
(
record
)
{
record
.
ports
.
blank?
}
...
@@ -27,6 +32,8 @@ module Gitlab
...
@@ -27,6 +32,8 @@ module Gitlab
entry
:ports
,
Entry
::
Ports
,
entry
:ports
,
Entry
::
Ports
,
description:
'Ports used to expose the service'
description:
'Ports used to expose the service'
attributes
:ports
def
alias
def
alias
value
[
:alias
]
value
[
:alias
]
end
end
...
@@ -34,6 +41,29 @@ module Gitlab
...
@@ -34,6 +41,29 @@ module Gitlab
def
command
def
command
value
[
:command
]
value
[
:command
]
end
end
def
name
value
[
:name
]
end
def
entrypoint
value
[
:entrypoint
]
end
def
value
return
{
name:
@config
}
if
string?
return
@config
if
hash
?
{}
end
def
with_image_ports?
opt
(:
with_image_ports
)
end
def
skip_config_hash_validation?
true
end
end
end
end
end
end
end
...
...
lib/gitlab/config/entry/configurable.rb
View file @
e6e812e2
...
@@ -75,7 +75,8 @@ module Gitlab
...
@@ -75,7 +75,8 @@ module Gitlab
# rubocop: disable CodeReuse/ActiveRecord
# rubocop: disable CodeReuse/ActiveRecord
def
entry
(
key
,
entry
,
description:
nil
,
default:
nil
,
inherit:
nil
,
reserved:
nil
,
metadata:
{})
def
entry
(
key
,
entry
,
description:
nil
,
default:
nil
,
inherit:
nil
,
reserved:
nil
,
metadata:
{})
raise
ArgumentError
,
"Entry
#{
key
}
already defined"
if
@nodes
.
to_h
[
key
.
to_sym
]
entry_name
=
key
.
to_sym
raise
ArgumentError
,
"Entry
#{
key
}
already defined"
if
@nodes
.
to_h
[
entry_name
]
factory
=
::
Gitlab
::
Config
::
Entry
::
Factory
.
new
(
entry
)
factory
=
::
Gitlab
::
Config
::
Entry
::
Factory
.
new
(
entry
)
.
with
(
description:
description
)
.
with
(
description:
description
)
...
@@ -84,10 +85,17 @@ module Gitlab
...
@@ -84,10 +85,17 @@ module Gitlab
.
with
(
reserved:
reserved
)
.
with
(
reserved:
reserved
)
.
metadata
(
metadata
)
.
metadata
(
metadata
)
(
@nodes
||=
{}).
merge!
(
key
.
to_sym
=>
factory
)
@nodes
||=
{}
@nodes
[
entry_name
]
=
factory
helpers
(
entry_name
)
end
end
# rubocop: enable CodeReuse/ActiveRecord
# rubocop: enable CodeReuse/ActiveRecord
def
dynamic_helpers
(
*
nodes
)
helpers
(
*
nodes
,
dynamic:
true
)
end
def
helpers
(
*
nodes
,
dynamic:
false
)
def
helpers
(
*
nodes
,
dynamic:
false
)
nodes
.
each
do
|
symbol
|
nodes
.
each
do
|
symbol
|
if
method_defined?
(
"
#{
symbol
}
_defined?"
)
||
method_defined?
(
"
#{
symbol
}
_value"
)
if
method_defined?
(
"
#{
symbol
}
_defined?"
)
||
method_defined?
(
"
#{
symbol
}
_value"
)
...
...
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