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
Léo-Paul Géneau
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
Show 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
before_action
:authorize_google_api
,
except:
[
:login
]
before_action
:authorize_google_project_billing
,
only:
[
:new
]
before_action
:authorize_create_cluster!
,
only:
[
:new
,
:create
]
before_action
:verify_billing
,
only:
[
:create
]
def
login
begin
...
...
@@ -23,24 +24,34 @@ class Projects::Clusters::GcpController < Projects::ApplicationController
end
def
create
case
google_project_billing_status
when
'true'
@cluster
=
::
Clusters
::
CreateService
.
new
(
project
,
current_user
,
create_params
)
.
execute
(
token_in_session
)
return
redirect_to
project_cluster_path
(
project
,
@cluster
)
if
@cluster
.
persisted?
if
@cluster
.
persisted?
redirect_to
project_cluster_path
(
project
,
@cluster
)
else
render
:new
end
end
private
def
verify_billing
case
google_project_billing_status
when
'true'
return
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
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
@cluster
=
::
Clusters
::
Cluster
.
new
(
create_params
)
render
:new
end
private
def
create_params
params
.
require
(
:cluster
).
permit
(
: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