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
250a8aee
Commit
250a8aee
authored
May 23, 2018
by
Dennis Tang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
revisions
parent
1b40d324
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
34 deletions
+21
-34
app/controllers/projects/clusters_controller.rb
app/controllers/projects/clusters_controller.rb
+20
-33
config/routes/project.rb
config/routes/project.rb
+1
-1
No files found.
app/controllers/projects/clusters_controller.rb
View file @
250a8aee
class
Projects::ClustersController
<
Projects
::
ApplicationController
before_action
:cluster
,
except:
[
:index
,
:new
,
:create
_cluster
]
before_action
:cluster
,
except:
[
:index
,
:new
,
:create
]
before_action
:authorize_read_cluster!
before_action
:generate_gcp_authorize_url
,
only:
[
:new
]
before_action
:new_cluster
,
only:
[
:new
]
before_action
:existing_cluster
,
only:
[
:new
]
before_action
:authorize_create_cluster!
,
only:
[
:new
]
before_action
:authorize_update_cluster!
,
only:
[
:update
]
before_action
:authorize_admin_cluster!
,
only:
[
:destroy
]
...
...
@@ -14,9 +17,6 @@ class Projects::ClustersController < Projects::ApplicationController
end
def
new
generate_gcp_authorize_url
tap_new_cluster
tap_existing_cluster
end
def
status
...
...
@@ -67,22 +67,7 @@ class Projects::ClustersController < Projects::ApplicationController
end
end
def
tap_new_cluster
if
GoogleApi
::
CloudPlatform
::
Client
.
new
(
token_in_session
,
nil
)
.
validate_token
(
expires_at_in_session
)
@new_cluster
=
::
Clusters
::
Cluster
.
new
.
tap
do
|
cluster
|
cluster
.
build_provider_gcp
end
end
end
def
tap_existing_cluster
@existing_cluster
=
::
Clusters
::
Cluster
.
new
.
tap
do
|
cluster
|
cluster
.
build_platform_kubernetes
end
end
def
create_cluster
def
create
case
params
[
:type
]
when
'new'
cluster_params
=
create_new_cluster_params
...
...
@@ -120,19 +105,6 @@ class Projects::ClustersController < Projects::ApplicationController
.
present
(
current_user:
current_user
)
end
def
create_params
params
.
require
(
:cluster
).
permit
(
:enabled
,
:name
,
:provider_type
,
provider_gcp_attributes:
[
:gcp_project_id
,
:zone
,
:num_nodes
,
:machine_type
])
end
def
update_params
if
cluster
.
managed?
params
.
require
(
:cluster
).
permit
(
...
...
@@ -199,6 +171,21 @@ class Projects::ClustersController < Projects::ApplicationController
# no-op
end
def
new_cluster
if
GoogleApi
::
CloudPlatform
::
Client
.
new
(
token_in_session
,
nil
)
.
validate_token
(
expires_at_in_session
)
@new_cluster
=
::
Clusters
::
Cluster
.
new
.
tap
do
|
cluster
|
cluster
.
build_provider_gcp
end
end
end
def
existing_cluster
@existing_cluster
=
::
Clusters
::
Cluster
.
new
.
tap
do
|
cluster
|
cluster
.
build_platform_kubernetes
end
end
def
token_in_session
@token_in_session
||=
session
[
GoogleApi
::
CloudPlatform
::
Client
.
session_key_for_token
]
...
...
config/routes/project.rb
View file @
250a8aee
...
...
@@ -206,7 +206,7 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
resources
:clusters
,
except:
[
:edit
,
:create
]
do
collection
do
post
'/new'
,
to:
'clusters#create
_cluster
'
post
'/new'
,
to:
'clusters#create'
end
member
do
...
...
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