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
0ca9ea6e
Commit
0ca9ea6e
authored
Oct 05, 2017
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Split create_params and update_params and fix small redirect bug in controller
parent
aba71835
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
13 deletions
+20
-13
app/controllers/projects/clusters_controller.rb
app/controllers/projects/clusters_controller.rb
+20
-13
No files found.
app/controllers/projects/clusters_controller.rb
View file @
0ca9ea6e
...
@@ -6,6 +6,14 @@ class Projects::ClustersController < Projects::ApplicationController
...
@@ -6,6 +6,14 @@ class Projects::ClustersController < Projects::ApplicationController
before_action
:authorize_update_cluster!
,
only:
[
:update
]
before_action
:authorize_update_cluster!
,
only:
[
:update
]
before_action
:authorize_admin_cluster!
,
only:
[
:destroy
]
before_action
:authorize_admin_cluster!
,
only:
[
:destroy
]
def
index
if
project
.
cluster
redirect_to
project_cluster_path
(
project
,
project
.
cluster
)
else
redirect_to
new_project_cluster_path
(
project
)
end
end
def
login
def
login
begin
begin
@authorize_url
=
GoogleApi
::
CloudPlatform
::
Client
.
new
(
@authorize_url
=
GoogleApi
::
CloudPlatform
::
Client
.
new
(
...
@@ -16,25 +24,17 @@ class Projects::ClustersController < Projects::ApplicationController
...
@@ -16,25 +24,17 @@ class Projects::ClustersController < Projects::ApplicationController
end
end
end
end
def
index
if
project
.
cluster
redirect_to
project_cluster_path
(
project
,
project
.
cluster
)
else
redirect_to
new_project_cluster_path
(
project
)
end
end
def
new
def
new
@cluster
=
project
.
build_cluster
@cluster
=
project
.
build_cluster
end
end
def
create
def
create
@cluster
=
Ci
::
CreateClusterService
@cluster
=
Ci
::
CreateClusterService
.
new
(
project
,
current_user
,
c
luster
_params
)
.
new
(
project
,
current_user
,
c
reate
_params
)
.
execute
(
token_in_session
)
.
execute
(
token_in_session
)
if
@cluster
.
persisted?
if
@cluster
.
persisted?
redirect_to
project_cluster
s_path
(
project
)
redirect_to
project_cluster
_path
(
project
,
@cluster
)
else
else
render
:new
render
:new
end
end
...
@@ -57,7 +57,7 @@ class Projects::ClustersController < Projects::ApplicationController
...
@@ -57,7 +57,7 @@ class Projects::ClustersController < Projects::ApplicationController
def
update
def
update
Ci
::
UpdateClusterService
Ci
::
UpdateClusterService
.
new
(
project
,
current_user
,
cluster
_params
)
.
new
(
project
,
current_user
,
update
_params
)
.
execute
(
cluster
)
.
execute
(
cluster
)
if
cluster
.
valid?
if
cluster
.
valid?
...
@@ -84,8 +84,9 @@ class Projects::ClustersController < Projects::ApplicationController
...
@@ -84,8 +84,9 @@ class Projects::ClustersController < Projects::ApplicationController
@cluster
||=
project
.
cluster
@cluster
||=
project
.
cluster
end
end
def
cluster_params
def
create_params
params
.
require
(
:cluster
).
permit
(
:gcp_project_id
,
params
.
require
(
:cluster
).
permit
(
:gcp_project_id
,
:gcp_cluster_zone
,
:gcp_cluster_zone
,
:gcp_cluster_name
,
:gcp_cluster_name
,
:gcp_cluster_size
,
:gcp_cluster_size
,
...
@@ -94,6 +95,12 @@ class Projects::ClustersController < Projects::ApplicationController
...
@@ -94,6 +95,12 @@ class Projects::ClustersController < Projects::ApplicationController
:enabled
)
:enabled
)
end
end
def
update_params
params
.
require
(
:cluster
).
permit
(
:project_namespace
,
:enabled
)
end
def
authorize_google_api
def
authorize_google_api
unless
GoogleApi
::
CloudPlatform
::
Client
.
new
(
token_in_session
,
nil
)
unless
GoogleApi
::
CloudPlatform
::
Client
.
new
(
token_in_session
,
nil
)
.
validate_token
(
expires_at_in_session
)
.
validate_token
(
expires_at_in_session
)
...
...
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