summaryrefslogtreecommitdiff
path: root/lib/google_api
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-02-11 18:18:58 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-02-11 18:18:58 +0000
commite57809ded8e4e64c0528d33a5f59e9160e310d14 (patch)
treee51a328a522b165b6b2465529b0adae0272b03dd /lib/google_api
parentec377e41624fb83f0e5e51286c7aad24a22eefb1 (diff)
downloadgitlab-ce-e57809ded8e4e64c0528d33a5f59e9160e310d14.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/google_api')
-rw-r--r--lib/google_api/cloud_platform/client.rb22
1 files changed, 21 insertions, 1 deletions
diff --git a/lib/google_api/cloud_platform/client.rb b/lib/google_api/cloud_platform/client.rb
index defcb33c5b6..43a2480d5b7 100644
--- a/lib/google_api/cloud_platform/client.rb
+++ b/lib/google_api/cloud_platform/client.rb
@@ -7,11 +7,12 @@ require 'google/apis/container_v1beta1'
require 'google/apis/cloudbilling_v1'
require 'google/apis/cloudresourcemanager_v1'
require 'google/apis/iam_v1'
+require 'google/apis/serviceusage_v1'
module GoogleApi
module CloudPlatform
class Client < GoogleApi::Auth
- SCOPE = 'https://www.googleapis.com/auth/cloud-platform'
+ SCOPE = 'https://www.googleapis.com/auth/cloud-platform https://www.googleapis.com/auth/service.management'
LEAST_TOKEN_LIFE_TIME = 10.minutes
CLUSTER_MASTER_AUTH_USERNAME = 'admin'
CLUSTER_IPV4_CIDR_BLOCK = '/16'
@@ -133,8 +134,27 @@ module GoogleApi
cloud_resource_manager_service.set_project_iam_policy(gcp_project_id, body)
end
+ def enable_cloud_run(gcp_project_id)
+ enable_service(gcp_project_id, 'run.googleapis.com')
+ end
+
+ def enable_artifacts_registry(gcp_project_id)
+ enable_service(gcp_project_id, 'artifactregistry.googleapis.com')
+ end
+
+ def enable_cloud_build(gcp_project_id)
+ enable_service(gcp_project_id, 'cloudbuild.googleapis.com')
+ end
+
private
+ def enable_service(gcp_project_id, service_name)
+ name = "projects/#{gcp_project_id}/services/#{service_name}"
+ service = Google::Apis::ServiceusageV1::ServiceUsageService.new
+ service.authorization = access_token
+ service.enable_service(name)
+ end
+
def make_cluster_options(cluster_name, cluster_size, machine_type, legacy_abac, enable_addons)
{
cluster: {