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
582e4014
Commit
582e4014
authored
Nov 30, 2017
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Restore unexpectedly removed code (Unrelated to this feature)
parent
232f4f1d
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
432 additions
and
20 deletions
+432
-20
app/models/clusters/platforms/kubernetes.rb
app/models/clusters/platforms/kubernetes.rb
+2
-0
app/models/environment.rb
app/models/environment.rb
+4
-0
app/models/project.rb
app/models/project.rb
+15
-8
app/serializers/environment_entity.rb
app/serializers/environment_entity.rb
+1
-1
app/views/projects/environments/_terminal_button.html.haml
app/views/projects/environments/_terminal_button.html.haml
+1
-1
spec/models/clusters/platforms/kubernetes_spec.rb
spec/models/clusters/platforms/kubernetes_spec.rb
+4
-1
spec/models/project_spec.rb
spec/models/project_spec.rb
+405
-9
No files found.
app/models/clusters/platforms/kubernetes.rb
View file @
582e4014
...
...
@@ -5,6 +5,8 @@ module Clusters
include
Gitlab
::
Kubernetes
include
ReactiveCaching
prepend
EE
::
KubernetesService
self
.
table_name
=
'cluster_platforms_kubernetes'
self
.
reactive_cache_key
=
->
(
kubernetes
)
{
[
kubernetes
.
class
.
model_name
.
singular
,
kubernetes
.
id
]
}
...
...
app/models/environment.rb
View file @
582e4014
...
...
@@ -145,6 +145,10 @@ class Environment < ActiveRecord::Base
project
.
deployment_platform
.
terminals
(
self
)
if
has_terminals?
end
def
rollout_status
project
.
deployment_platform
.
rollout_status
(
self
)
if
has_terminals?
end
def
has_metrics?
project
.
monitoring_service
.
present?
&&
available?
&&
last_deployment
.
present?
end
...
...
app/models/project.rb
View file @
582e4014
...
...
@@ -20,6 +20,9 @@ class Project < ActiveRecord::Base
include
GroupDescendant
include
Gitlab
::
SQL
::
Pattern
# EE specific modules
prepend
EE
::
Project
extend
Gitlab
::
ConfigHelper
extend
Gitlab
::
CurrentSettings
...
...
@@ -100,6 +103,7 @@ class Project < ActiveRecord::Base
# Project services
has_one
:campfire_service
has_one
:drone_ci_service
has_one
:gitlab_slack_application_service
has_one
:emails_on_push_service
has_one
:pipelines_email_service
has_one
:irker_service
...
...
@@ -390,10 +394,6 @@ class Project < ActiveRecord::Base
transition
[
:scheduled
,
:started
]
=>
:failed
end
event
:import_retry
do
transition
failed: :started
end
state
:scheduled
state
:started
state
:finished
...
...
@@ -482,6 +482,14 @@ class Project < ActiveRecord::Base
.
base_and_ancestors
(
upto:
top
)
end
def
root_namespace
if
namespace
.
has_parent?
namespace
.
root_ancestor
else
namespace
end
end
def
lfs_enabled?
return
namespace
.
lfs_enabled?
if
self
[
:lfs_enabled
].
nil?
...
...
@@ -617,6 +625,8 @@ class Project < ActiveRecord::Base
else
super
end
rescue
super
end
def
valid_import_url?
...
...
@@ -1040,6 +1050,7 @@ class Project < ActiveRecord::Base
# Expires various caches before a project is renamed.
def
expire_caches_before_rename
(
old_path
)
# TODO: if we start using UUIDs for cache, we don't need to do this HACK anymore
repo
=
Repository
.
new
(
old_path
,
self
)
wiki
=
Repository
.
new
(
"
#{
old_path
}
.wiki"
,
self
)
...
...
@@ -1619,10 +1630,6 @@ class Project < ActiveRecord::Base
feature_available?
(
:multiple_issue_boards
,
user
)
end
def
issue_board_milestone_available?
(
user
=
nil
)
feature_available?
(
:issue_board_milestone
,
user
)
end
def
full_path_was
File
.
join
(
namespace
.
full_path
,
previous_changes
[
'path'
].
first
)
end
...
...
app/serializers/environment_entity.rb
View file @
582e4014
...
...
@@ -23,7 +23,7 @@ class EnvironmentEntity < Grape::Entity
stop_project_environment_path
(
environment
.
project
,
environment
)
end
expose
:terminal_path
,
if:
->
(
*
)
{
environment
.
deployment_service_ready
?
}
do
|
environment
|
expose
:terminal_path
,
if:
->
(
*
)
{
environment
.
has_terminals
?
}
do
|
environment
|
can?
(
request
.
current_user
,
:admin_environment
,
environment
.
project
)
&&
terminal_project_environment_path
(
environment
.
project
,
environment
)
end
...
...
app/views/projects/environments/_terminal_button.html.haml
View file @
582e4014
-
if
environment
.
deployment_service_ready
?
&&
can?
(
current_user
,
:admin_environment
,
@project
)
-
if
environment
.
has_terminals
?
&&
can?
(
current_user
,
:admin_environment
,
@project
)
=
link_to
terminal_project_environment_path
(
@project
,
environment
),
class:
'btn terminal-button'
do
=
icon
(
'terminal'
)
spec/models/clusters/platforms/kubernetes_spec.rb
View file @
582e4014
...
...
@@ -242,6 +242,7 @@ describe Clusters::Platforms::Kubernetes, :use_clean_rails_memory_store_caching
context
'when kubernetes responds with valid pods'
do
before
do
stub_kubeclient_pods
stub_kubeclient_deployments
end
it
{
is_expected
.
to
eq
(
pods:
[
kube_pod
])
}
...
...
@@ -250,6 +251,7 @@ describe Clusters::Platforms::Kubernetes, :use_clean_rails_memory_store_caching
context
'when kubernetes responds with 500s'
do
before
do
stub_kubeclient_pods
(
status:
500
)
stub_kubeclient_deployments
(
status:
500
)
end
it
{
expect
{
subject
}.
to
raise_error
(
KubeException
)
}
...
...
@@ -258,9 +260,10 @@ describe Clusters::Platforms::Kubernetes, :use_clean_rails_memory_store_caching
context
'when kubernetes responds with 404s'
do
before
do
stub_kubeclient_pods
(
status:
404
)
stub_kubeclient_deployments
(
status:
404
)
end
it
{
is_expected
.
to
eq
(
pods:
[])
}
it
{
is_expected
.
to
eq
(
pods:
[]
,
deployments:
[]
)
}
end
end
end
spec/models/project_spec.rb
View file @
582e4014
This diff is collapsed.
Click to expand it.
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