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
cf6258af
Commit
cf6258af
authored
Jan 10, 2018
by
Kamil Trzciński
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix billing checking
parent
b44583e9
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
9 additions
and
6 deletions
+9
-6
app/controllers/projects/clusters/gcp_controller.rb
app/controllers/projects/clusters/gcp_controller.rb
+1
-1
app/services/check_gcp_project_billing_service.rb
app/services/check_gcp_project_billing_service.rb
+4
-1
app/workers/check_gcp_project_billing_worker.rb
app/workers/check_gcp_project_billing_worker.rb
+2
-2
lib/google_api/cloud_platform/client.rb
lib/google_api/cloud_platform/client.rb
+2
-2
No files found.
app/controllers/projects/clusters/gcp_controller.rb
View file @
cf6258af
class
Projects::Clusters::GcpController
<
Projects
::
ApplicationController
class
Projects::Clusters::GcpController
<
Projects
::
ApplicationController
before_action
:authorize_read_cluster!
before_action
:authorize_read_cluster!
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
,
:create
]
before_action
:authorize_create_cluster!
,
only:
[
:new
,
:create
]
before_action
:authorize_create_cluster!
,
only:
[
:new
,
:create
]
before_action
:verify_billing
,
only:
[
:create
]
before_action
:verify_billing
,
only:
[
:create
]
...
...
app/services/check_gcp_project_billing_service.rb
View file @
cf6258af
...
@@ -2,7 +2,10 @@ class CheckGcpProjectBillingService
...
@@ -2,7 +2,10 @@ class CheckGcpProjectBillingService
def
execute
(
token
)
def
execute
(
token
)
client
=
GoogleApi
::
CloudPlatform
::
Client
.
new
(
token
,
nil
)
client
=
GoogleApi
::
CloudPlatform
::
Client
.
new
(
token
,
nil
)
client
.
projects_list
.
select
do
|
project
|
client
.
projects_list
.
select
do
|
project
|
client
.
projects_get_billing_info
(
project
.
name
).
billingEnabled
begin
client
.
projects_get_billing_info
(
project
.
project_id
).
billing_enabled
rescue
end
end
end
end
end
end
end
app/workers/check_gcp_project_billing_worker.rb
View file @
cf6258af
...
@@ -23,13 +23,13 @@ class CheckGcpProjectBillingWorker
...
@@ -23,13 +23,13 @@ class CheckGcpProjectBillingWorker
end
end
def
self
.
redis_shared_state_key_for
(
token
)
def
self
.
redis_shared_state_key_for
(
token
)
"gitlab:gcp:
#{
token
.
hash
}
:billing_enabled"
"gitlab:gcp:
#{
Digest
::
SHA1
.
hexdigest
(
token
)
}
:billing_enabled"
end
end
def
perform
(
token_key
)
def
perform
(
token_key
)
return
unless
token_key
return
unless
token_key
token
=
self
.
get_session_token
(
token_key
)
token
=
self
.
class
.
get_session_token
(
token_key
)
return
unless
token
return
unless
token
return
unless
try_obtain_lease_for
(
token
)
return
unless
try_obtain_lease_for
(
token
)
...
...
lib/google_api/cloud_platform/client.rb
View file @
cf6258af
...
@@ -51,11 +51,11 @@ module GoogleApi
...
@@ -51,11 +51,11 @@ module GoogleApi
end
end
end
end
def
projects_get_billing_info
(
project_
name
)
def
projects_get_billing_info
(
project_
id
)
service
=
Google
::
Apis
::
CloudbillingV1
::
CloudbillingService
.
new
service
=
Google
::
Apis
::
CloudbillingV1
::
CloudbillingService
.
new
service
.
authorization
=
access_token
service
.
authorization
=
access_token
service
.
get_project_billing_info
(
"projects/
#{
project_
name
}
"
)
service
.
get_project_billing_info
(
"projects/
#{
project_
id
}
"
)
end
end
def
projects_zones_clusters_get
(
project_id
,
zone
,
cluster_id
)
def
projects_zones_clusters_get
(
project_id
,
zone
,
cluster_id
)
...
...
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