Class: GoogleCloud::CreateServiceAccountsService
- Inherits:
-
BaseService
- Object
- BaseService
- BaseService
- GoogleCloud::CreateServiceAccountsService
- Defined in:
- app/services/google_cloud/create_service_accounts_service.rb
Instance Attribute Summary
Attributes inherited from BaseService
#current_user, #params, #project
Instance Method Summary collapse
Methods inherited from BaseService
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
Constructor Details
This class inherits a constructor from BaseService
Instance Method Details
#execute ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'app/services/google_cloud/create_service_accounts_service.rb', line 5 def execute service_account = google_api_client.create_service_account(gcp_project_id, service_account_name, service_account_desc) service_account_key = google_api_client.create_service_account_key(gcp_project_id, service_account.unique_id) google_api_client.grant_service_account_roles(gcp_project_id, service_account.email) service_accounts_service.add_for_project( environment_name, service_account.project_id, Gitlab::Json.dump(service_account), Gitlab::Json.dump(service_account_key), ProtectedBranch.protected?(project, environment_name) || ProtectedTag.protected?(project, environment_name) ) ServiceResponse.success(message: _('Service account generated successfully'), payload: { service_account: service_account, service_account_key: service_account_key }) end |