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
Jérome Perrin
gitlab-ce
Commits
25076520
Commit
25076520
authored
Oct 03, 2017
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Introduce serializer for ClusterEntity
parent
65b4627d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
10 deletions
+34
-10
app/controllers/projects/clusters_controller.rb
app/controllers/projects/clusters_controller.rb
+21
-10
app/serializers/cluster_entity.rb
app/serializers/cluster_entity.rb
+6
-0
app/serializers/cluster_serializer.rb
app/serializers/cluster_serializer.rb
+7
-0
No files found.
app/controllers/projects/clusters_controller.rb
View file @
25076520
...
...
@@ -46,10 +46,9 @@ class Projects::ClustersController < Projects::ApplicationController
format
.
json
do
Gitlab
::
PollingInterval
.
set_header
(
response
,
interval:
10_000
)
render
json:
{
status:
cluster
.
status
,
# The current status of the operation.
status_reason:
cluster
.
status_reason
# If an error has occurred, a textual description of the error.
}
render
json:
ClusterSerializer
.
new
(
project:
@project
,
current_user:
@current_user
)
.
represent_status
(
@cluster
)
end
end
end
...
...
@@ -62,7 +61,15 @@ class Projects::ClustersController < Projects::ApplicationController
.
new
(
project
,
current_user
,
cluster_params
)
.
execute
(
cluster
)
render
:show
respond_to
do
|
format
|
format
.
html
do
render
:show
end
format
.
json
do
head
:no_data
end
end
end
def
destroy
...
...
@@ -80,9 +87,13 @@ class Projects::ClustersController < Projects::ApplicationController
end
def
cluster_params
params
.
require
(
:cluster
)
.
permit
(
:gcp_project_id
,
:gcp_cluster_zone
,
:gcp_cluster_name
,
:gcp_cluster_size
,
:gcp_machine_type
,
:project_namespace
,
:enabled
)
params
.
require
(
:cluster
).
permit
(
:gcp_project_id
,
:gcp_cluster_zone
,
:gcp_cluster_name
,
:gcp_cluster_size
,
:gcp_machine_type
,
:project_namespace
,
:enabled
)
end
def
authorize_google_api
...
...
@@ -103,10 +114,10 @@ class Projects::ClustersController < Projects::ApplicationController
end
def
authorize_update_cluster!
return
access_denied!
unless
can?
(
current_user
,
:update_cluster
,
cluster
)
access_denied!
unless
can?
(
current_user
,
:update_cluster
,
cluster
)
end
def
authorize_admin_cluster!
return
access_denied!
unless
can?
(
current_user
,
:admin_cluster
,
cluster
)
access_denied!
unless
can?
(
current_user
,
:admin_cluster
,
cluster
)
end
end
app/serializers/cluster_entity.rb
0 → 100644
View file @
25076520
class
ClusterEntity
<
Grape
::
Entity
include
RequestAwareEntity
expose
:status
expose
:status_reason
end
app/serializers/cluster_serializer.rb
0 → 100644
View file @
25076520
class
ClusterSerializer
<
BaseSerializer
entity
ClusterEntity
def
represent_status
(
resource
)
represent
(
resource
,
{
only:
[
:status
,
:status_reason
]
})
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