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
59f87e73
Commit
59f87e73
authored
Sep 14, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement CI/CD kubernetes policy specification
parent
bff004d4
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
77 additions
and
0 deletions
+77
-0
lib/gitlab/ci/build/policy/kubernetes.rb
lib/gitlab/ci/build/policy/kubernetes.rb
+19
-0
lib/gitlab/ci/build/policy/specification.rb
lib/gitlab/ci/build/policy/specification.rb
+28
-0
spec/lib/gitlab/ci/build/policy/kubernetes_spec.rb
spec/lib/gitlab/ci/build/policy/kubernetes_spec.rb
+30
-0
No files found.
lib/gitlab/ci/build/policy/kubernetes.rb
0 → 100644
View file @
59f87e73
module
Gitlab
module
Ci
module
Build
module
Policy
class
Kubernetes
<
Policy
::
Specification
def
initialize
(
spec
)
unless
spec
.
to_sym
==
:active
raise
UnknownPolicyError
end
end
def
satisfied_by?
(
pipeline
,
**
_
)
pipeline
.
has_kubernetes_active?
end
end
end
end
end
end
lib/gitlab/ci/build/policy/specification.rb
0 → 100644
View file @
59f87e73
module
Gitlab
module
Ci
module
Build
module
Policy
##
# Abstract class that defines an intereface of job policy
# specification.
#
# Used for job's only/except policy configuration.
#
class
Specification
UnknownPolicyError
=
Class
.
new
(
StandardError
)
def
initialize
(
spec
)
@spec
=
spec
end
def
satisfied_by?
(
pipeline
,
**
metadata
)
raise
NotImplementedError
end
def
self
.
fabricate_all
(
*
specs
)
end
end
end
end
end
end
spec/lib/gitlab/ci/build/policy/kubernetes_spec.rb
0 → 100644
View file @
59f87e73
require
'spec_helper'
describe
Gitlab
::
Ci
::
Build
::
Policy
::
Kubernetes
do
let
(
:pipeline
)
{
create
(
:ci_pipeline
,
project:
project
)
}
context
'when kubernetes service is active'
do
set
(
:project
)
{
create
(
:kubernetes_project
)
}
it
'is satisfied by a kubernetes pipeline'
do
expect
(
described_class
.
new
(
'active'
))
.
to
be_satisfied_by
(
pipeline
)
end
end
context
'when kubernetes service is inactive'
do
set
(
:project
)
{
create
(
:project
)
}
it
'is not satisfied by a pipeline without kubernetes available'
do
expect
(
described_class
.
new
(
'active'
))
.
not_to
be_satisfied_by
(
pipeline
)
end
end
context
'when kubernetes policy is invalid'
do
it
'raises an error'
do
expect
{
described_class
.
new
(
'unknown'
)
}
.
to
raise_error
described_class
::
UnknownPolicyError
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