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
8a3d61ba
Commit
8a3d61ba
authored
May 31, 2017
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Kubernetes service specs
parent
cecd2699
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
26 deletions
+7
-26
app/models/project_services/kubernetes_service.rb
app/models/project_services/kubernetes_service.rb
+5
-6
spec/models/project_services/kubernetes_service_spec.rb
spec/models/project_services/kubernetes_service_spec.rb
+0
-18
spec/support/kubernetes_helpers.rb
spec/support/kubernetes_helpers.rb
+2
-2
No files found.
app/models/project_services/kubernetes_service.rb
View file @
8a3d61ba
...
@@ -116,10 +116,9 @@ class KubernetesService < DeploymentService
...
@@ -116,10 +116,9 @@ class KubernetesService < DeploymentService
# short time later
# short time later
def
terminals
(
environment
)
def
terminals
(
environment
)
with_reactive_cache
do
|
data
|
with_reactive_cache
do
|
data
|
pods
=
data
.
fetch
(
:pods
,
nil
)
pods
=
filter_by_label
(
data
[
:pods
],
app:
environment
.
slug
)
filter_pods
(
pods
,
app:
environment
.
slug
).
terminals
=
pods
.
flat_map
{
|
pod
|
terminals_for_pod
(
api_url
,
actual_namespace
,
pod
)
}
flat_map
{
|
pod
|
terminals_for_pod
(
api_url
,
actual_namespace
,
pod
)
}.
terminals
.
each
{
|
terminal
|
add_terminal_auth
(
terminal
,
terminal_auth
)
}
each
{
|
terminal
|
add_terminal_auth
(
terminal
,
terminal_auth
)
}
end
end
end
end
...
@@ -168,7 +167,7 @@ class KubernetesService < DeploymentService
...
@@ -168,7 +167,7 @@ class KubernetesService < DeploymentService
def
read_pods
def
read_pods
kubeclient
=
build_kubeclient!
kubeclient
=
build_kubeclient!
kubeclient
.
get_pods
(
namespace:
namespace
).
as_json
kubeclient
.
get_pods
(
namespace:
actual_
namespace
).
as_json
rescue
KubeException
=>
err
rescue
KubeException
=>
err
raise
err
unless
err
.
error_code
==
404
raise
err
unless
err
.
error_code
==
404
[]
[]
...
@@ -177,7 +176,7 @@ class KubernetesService < DeploymentService
...
@@ -177,7 +176,7 @@ class KubernetesService < DeploymentService
def
read_deployments
def
read_deployments
kubeclient
=
build_kubeclient!
(
api_path:
'apis/extensions'
,
api_version:
'v1beta1'
)
kubeclient
=
build_kubeclient!
(
api_path:
'apis/extensions'
,
api_version:
'v1beta1'
)
kubeclient
.
get_deployments
(
namespace:
namespace
).
as_json
kubeclient
.
get_deployments
(
namespace:
actual_
namespace
).
as_json
rescue
KubeException
=>
err
rescue
KubeException
=>
err
raise
err
unless
err
.
error_code
==
404
raise
err
unless
err
.
error_code
==
404
[]
[]
...
...
spec/models/project_services/kubernetes_service_spec.rb
View file @
8a3d61ba
...
@@ -7,24 +7,6 @@ describe KubernetesService, models: true, caching: true do
...
@@ -7,24 +7,6 @@ describe KubernetesService, models: true, caching: true do
let
(
:project
)
{
build_stubbed
(
:kubernetes_project
)
}
let
(
:project
)
{
build_stubbed
(
:kubernetes_project
)
}
let
(
:service
)
{
project
.
kubernetes_service
}
let
(
:service
)
{
project
.
kubernetes_service
}
# We use Kubeclient to interactive with the Kubernetes API. It will
# GET /api/v1 for a list of resources the API supports. This must be stubbed
# in addition to any other HTTP requests we expect it to perform.
let
(
:discovery_url
)
{
service
.
api_url
+
'/api/v1'
}
let
(
:discovery_response
)
{
{
body:
kube_discovery_body
.
to_json
}
}
let
(
:pods_url
)
{
service
.
api_url
+
"/api/v1/namespaces/
#{
service
.
actual_namespace
}
/pods"
}
let
(
:pods_response
)
{
{
body:
kube_pods_body
(
kube_pod
).
to_json
}
}
def
stub_kubeclient_discover
WebMock
.
stub_request
(
:get
,
discovery_url
).
to_return
(
discovery_response
)
end
def
stub_kubeclient_pods
stub_kubeclient_discover
WebMock
.
stub_request
(
:get
,
pods_url
).
to_return
(
pods_response
)
end
describe
"Associations"
do
describe
"Associations"
do
it
{
is_expected
.
to
belong_to
:project
}
it
{
is_expected
.
to
belong_to
:project
}
end
end
...
...
spec/support/kubernetes_helpers.rb
View file @
8a3d61ba
...
@@ -20,14 +20,14 @@ module KubernetesHelpers
...
@@ -20,14 +20,14 @@ module KubernetesHelpers
def
stub_kubeclient_pods
(
response
=
nil
)
def
stub_kubeclient_pods
(
response
=
nil
)
stub_kubeclient_discover
stub_kubeclient_discover
pods_url
=
service
.
api_url
+
"/api/v1/namespaces/
#{
service
.
namespace
}
/pods"
pods_url
=
service
.
api_url
+
"/api/v1/namespaces/
#{
service
.
actual_
namespace
}
/pods"
WebMock
.
stub_request
(
:get
,
pods_url
).
to_return
(
response
||
kube_pods_response
)
WebMock
.
stub_request
(
:get
,
pods_url
).
to_return
(
response
||
kube_pods_response
)
end
end
def
stub_kubeclient_deployments
(
response
=
nil
)
def
stub_kubeclient_deployments
(
response
=
nil
)
stub_kubeclient_discover
stub_kubeclient_discover
deployments_url
=
service
.
api_url
+
"/apis/extensions/v1beta1/namespaces/
#{
service
.
namespace
}
/deployments"
deployments_url
=
service
.
api_url
+
"/apis/extensions/v1beta1/namespaces/
#{
service
.
actual_
namespace
}
/deployments"
WebMock
.
stub_request
(
:get
,
deployments_url
).
to_return
(
response
||
kube_deployments_response
)
WebMock
.
stub_request
(
:get
,
deployments_url
).
to_return
(
response
||
kube_deployments_response
)
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