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
ef030709
Commit
ef030709
authored
Aug 31, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change kubernetes job policy allowed values
It is now possible to use `kubernetes: configured`.
parent
92673c2c
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
56 additions
and
5 deletions
+56
-5
lib/ci/gitlab_ci_yaml_processor.rb
lib/ci/gitlab_ci_yaml_processor.rb
+2
-3
lib/gitlab/ci/config/entry/policy.rb
lib/gitlab/ci/config/entry/policy.rb
+1
-1
lib/gitlab/ci/config/entry/validators.rb
lib/gitlab/ci/config/entry/validators.rb
+8
-0
spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
+1
-1
spec/lib/gitlab/ci/config/entry/policy_spec.rb
spec/lib/gitlab/ci/config/entry/policy_spec.rb
+44
-0
No files found.
lib/ci/gitlab_ci_yaml_processor.rb
View file @
ef030709
...
...
@@ -99,7 +99,6 @@ module Ci
end
end
def
jobs_for_ref
(
ref
,
tag
=
false
,
source
=
nil
)
@jobs
.
select
do
|
_
,
job
|
process?
(
job
.
dig
(
:only
,
:refs
),
job
.
dig
(
:except
,
:refs
),
ref
,
tag
,
source
)
...
...
lib/gitlab/ci/config/entry/policy.rb
View file @
ef030709
...
...
@@ -33,7 +33,7 @@ module Gitlab
with_options
allow_nil:
true
do
validates
:refs
,
array_of_strings_or_regexps:
true
validates
:kubernetes
,
inclusion:
{
in:
[
true
]
}
validates
:kubernetes
,
allowed_values:
%w[configured]
end
end
end
...
...
lib/gitlab/ci/config/entry/validators.rb
View file @
ef030709
...
...
@@ -14,6 +14,14 @@ module Gitlab
end
end
class
AllowedValuesValidator
<
ActiveModel
::
EachValidator
def
validate_each
(
record
,
attribute
,
value
)
unless
options
[
:in
].
include?
(
value
.
to_s
)
record
.
errors
.
add
(
attribute
,
"unknown value:
#{
value
}
"
)
end
end
end
class
ArrayOfStringsValidator
<
ActiveModel
::
EachValidator
include
LegacyValidationHelpers
...
...
spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
View file @
ef030709
...
...
@@ -172,7 +172,7 @@ module Ci
YAML
.
dump
(
spinach:
{
stage:
'test'
,
script:
'spinach'
},
production:
{
stage:
'deploy'
,
script:
'cap'
,
only:
{
kubernetes:
true
}
}
kubernetes:
'configured'
}
}
)
end
...
...
spec/lib/gitlab/ci/config/entry/policy_spec.rb
View file @
ef030709
...
...
@@ -56,6 +56,50 @@ describe Gitlab::Ci::Config::Entry::Policy do
end
end
context
'when using complex policy'
do
context
'when specifiying refs policy'
do
let
(
:config
)
{
{
refs:
[
'master'
]
}
}
it
'is a correct configuraton'
do
expect
(
entry
).
to
be_valid
expect
(
entry
.
value
).
to
eq
(
refs:
%w[master]
)
end
end
context
'when specifying kubernetes policy'
do
let
(
:config
)
{
{
kubernetes:
'configured'
}
}
it
'is a correct configuraton'
do
expect
(
entry
).
to
be_valid
expect
(
entry
.
value
).
to
eq
(
kubernetes:
'configured'
)
end
end
context
'when specifying invalid kubernetes policy'
do
let
(
:config
)
{
{
kubernetes:
'active'
}
}
it
'reports an error about invalid policy'
do
expect
(
entry
.
errors
).
to
include
/unknown value: active/
end
end
context
'when specifying unknown policy'
do
let
(
:config
)
{
{
refs:
[
'master'
],
invalid: :something
}
}
it
'returns error about invalid key'
do
expect
(
entry
.
errors
).
to
include
/unknown keys: invalid/
end
end
context
'when policy is empty'
do
let
(
:config
)
{
{}
}
it
'is not a valid configuration'
do
expect
(
entry
.
errors
).
to
include
/can't be blank/
end
end
end
context
'when policy strategy does not match'
do
let
(
:config
)
{
'string strategy'
}
...
...
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