Skip to content
GitLab
Next
Menu
Why GitLab
Pricing
Contact Sales
Explore
Why GitLab
Pricing
Contact Sales
Explore
Sign in
Get free trial
Primary navigation
Search or go to…
Project
GitLab
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Privacy statement
Keyboard shortcuts
?
What's new
4
Snippets
Groups
Projects
Show more breadcrumbs
GitLab.org
GitLab
Commits
250a8aee
Commit
250a8aee
authored
6 years ago
by
Dennis Tang
Browse files
Options
Downloads
Patches
Plain Diff
revisions
parent
1b40d324
No related branches found
No related tags found
2 merge requests
!6393
CE upstream - 2018-07-05 12:27 UTC
,
!6387
Prepare 11.1 RC5 EE release
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/controllers/projects/clusters_controller.rb
+20
-33
20 additions, 33 deletions
app/controllers/projects/clusters_controller.rb
config/routes/project.rb
+1
-1
1 addition, 1 deletion
config/routes/project.rb
with
21 additions
and
34 deletions
app/controllers/projects/clusters_controller.rb
+
20
−
33
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 @@ def index
end
def
new
generate_gcp_authorize_url
tap_new_cluster
tap_existing_cluster
end
def
status
...
...
@@ -67,22 +67,7 @@ def destroy
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 @@ def cluster
.
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 @@ def generate_gcp_authorize_url
# 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
]
...
...
This diff is collapsed.
Click to expand it.
config/routes/project.rb
+
1
−
1
View file @
250a8aee
...
...
@@ -206,7 +206,7 @@
resources
:clusters
,
except:
[
:edit
,
:create
]
do
collection
do
post
'/new'
,
to:
'clusters#create
_cluster
'
post
'/new'
,
to:
'clusters#create'
end
member
do
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment