Class: GoogleCloud::EnableCloudsqlService

Inherits:
BaseService show all
Defined in:
app/services/google_cloud/enable_cloudsql_service.rb

Instance Attribute Summary

Attributes inherited from BaseService

#current_user, #params, #project

Instance Method Summary collapse

Methods inherited from BaseService

#initialize

Methods included from BaseServiceUtility

#deny_visibility_level, #event_service, #log_error, #log_info, #notification_service, #system_hook_service, #todo_service, #visibility_level

Methods included from Gitlab::Allowable

#can?

Constructor Details

This class inherits a constructor from BaseService

Instance Method Details

#executeObject



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'app/services/google_cloud/enable_cloudsql_service.rb', line 5

def execute
  create_or_replace_project_vars(environment_name, 'GCP_PROJECT_ID', gcp_project_id, ci_var_protected?)

  unique_gcp_project_ids.each do |gcp_project_id|
    google_api_client.enable_cloud_sql_admin(gcp_project_id)
    google_api_client.enable_compute(gcp_project_id)
    google_api_client.enable_service_networking(gcp_project_id)
  end

  success({ gcp_project_ids: unique_gcp_project_ids })
rescue Google::Apis::Error => err
  error(err.message)
end