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
b44583e9
Commit
b44583e9
authored
Jan 10, 2018
by
Matija Čupić
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract GCP billing check as method
parent
be623ef3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
9 deletions
+20
-9
app/controllers/projects/clusters/gcp_controller.rb
app/controllers/projects/clusters/gcp_controller.rb
+20
-9
No files found.
app/controllers/projects/clusters/gcp_controller.rb
View file @
b44583e9
...
@@ -3,6 +3,7 @@ class Projects::Clusters::GcpController < Projects::ApplicationController
...
@@ -3,6 +3,7 @@ class Projects::Clusters::GcpController < Projects::ApplicationController
before_action
:authorize_google_api
,
except:
[
:login
]
before_action
:authorize_google_api
,
except:
[
:login
]
before_action
:authorize_google_project_billing
,
only:
[
:new
]
before_action
:authorize_google_project_billing
,
only:
[
:new
]
before_action
:authorize_create_cluster!
,
only:
[
:new
,
:create
]
before_action
:authorize_create_cluster!
,
only:
[
:new
,
:create
]
before_action
:verify_billing
,
only:
[
:create
]
def
login
def
login
begin
begin
...
@@ -23,24 +24,34 @@ class Projects::Clusters::GcpController < Projects::ApplicationController
...
@@ -23,24 +24,34 @@ class Projects::Clusters::GcpController < Projects::ApplicationController
end
end
def
create
def
create
@cluster
=
::
Clusters
::
CreateService
.
new
(
project
,
current_user
,
create_params
)
.
execute
(
token_in_session
)
if
@cluster
.
persisted?
redirect_to
project_cluster_path
(
project
,
@cluster
)
else
render
:new
end
end
private
def
verify_billing
case
google_project_billing_status
case
google_project_billing_status
when
'true'
when
'true'
@cluster
=
::
Clusters
::
CreateService
return
.
new
(
project
,
current_user
,
create_params
)
.
execute
(
token_in_session
)
return
redirect_to
project_cluster_path
(
project
,
@cluster
)
if
@cluster
.
persisted?
when
'false'
when
'false'
flash
[
:
error
]
=
_
(
'Please enable billing for one of your projects to be able to create a cluster.'
)
flash
[
:
alert
]
=
_
(
'Please enable billing for one of your projects to be able to create a cluster.'
)
else
else
flash
[
:
error
]
=
_
(
'We could not verify that one of your projects on GCP has billing enabled. Please try again.'
)
flash
[
:
alert
]
=
_
(
'We could not verify that one of your projects on GCP has billing enabled. Please try again.'
)
end
end
@cluster
=
::
Clusters
::
Cluster
.
new
(
create_params
)
render
:new
render
:new
end
end
private
def
create_params
def
create_params
params
.
require
(
:cluster
).
permit
(
params
.
require
(
:cluster
).
permit
(
:enabled
,
:enabled
,
...
...
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