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
73d0cafb
Commit
73d0cafb
authored
Sep 01, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check if service active when using CI/CD kubernetes policy
parent
dc4d9386
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
44 deletions
+9
-44
app/models/ci/pipeline.rb
app/models/ci/pipeline.rb
+2
-13
lib/ci/gitlab_ci_yaml_processor.rb
lib/ci/gitlab_ci_yaml_processor.rb
+1
-1
spec/models/ci/pipeline_spec.rb
spec/models/ci/pipeline_spec.rb
+6
-30
No files found.
app/models/ci/pipeline.rb
View file @
73d0cafb
...
...
@@ -304,19 +304,8 @@ module Ci
@stage_seeds
||=
config_processor
.
stage_seeds
(
self
)
end
def
context_variables
@context_variables
||=
project
.
secret_variables_for
(
ref:
ref
).
to_a
.
map
(
&
:to_runner_variable
)
+
project
.
deployment_variables
.
to_a
end
def
has_kubernetes_available?
kubernetes_variables
=
context_variables
.
select
do
|
variable
|
variable
.
fetch
(
:key
).
in?
(
%w[KUBECONFIG KUBE_DOMAIN]
)
end
return
false
if
kubernetes_variables
.
empty?
kubernetes_variables
.
map
{
|
var
|
var
.
fetch
(
:value
).
present?
}.
all?
def
has_kubernetes_active?
project
.
kubernetes_service
&
.
active?
end
def
has_stage_seeds?
...
...
lib/ci/gitlab_ci_yaml_processor.rb
View file @
73d0cafb
...
...
@@ -89,7 +89,7 @@ module Ci
builds
.
select
do
|
build
|
job
=
@jobs
[
build
.
fetch
(
:name
).
to_sym
]
has_kubernetes
=
pipeline
.
has_kubernetes_a
vailabl
e?
has_kubernetes
=
pipeline
.
has_kubernetes_a
ctiv
e?
only_kubernetes
=
job
.
dig
(
:only
,
:kubernetes
)
except_kubernetes
=
job
.
dig
(
:except
,
:kubernetes
)
...
...
spec/models/ci/pipeline_spec.rb
View file @
73d0cafb
...
...
@@ -546,42 +546,18 @@ describe Ci::Pipeline, :mailer do
end
end
describe
'#has_kubernetes_active?'
do
context
'when kubernetes is configured'
do
let
(
:project
)
{
create
(
:kubernetes_project
)
}
before
do
create
(
:ci_variable
,
key:
'KUBE_DOMAIN'
,
protected:
false
,
project:
project
)
end
describe
'#context_variables'
do
it
'returns kubernetes-related variables'
do
variables
=
pipeline
.
context_variables
.
map
{
|
v
|
v
.
fetch
(
:key
)
}
expect
(
variables
).
to
include
'KUBECONFIG'
,
'KUBE_DOMAIN'
end
end
describe
'#has_kubernetes_available?'
do
it
'returns true'
do
expect
(
pipeline
).
to
have_kubernetes_available
end
expect
(
pipeline
).
to
have_kubernetes_active
end
end
context
'when kubernetes is not configured'
do
describe
'#context_variables'
do
it
'does not return kubernetes related variables'
do
variables
=
pipeline
.
context_variables
.
map
{
|
v
|
v
.
fetch
(
:key
)
}
expect
(
variables
).
not_to
include
'KUBECONFIG'
,
'KUBE_DOMAIN'
end
end
describe
'#has_kubernetes_available?'
do
it
'returns false'
do
expect
(
pipeline
).
not_to
have_kubernetes_a
vailabl
e
expect
(
pipeline
).
not_to
have_kubernetes_a
ctiv
e
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