Class: GoogleCloud::CreateServiceAccountsService

Inherits:
BaseService show all
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

#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
18
19
20
21
22
# File 'app/services/google_cloud/create_service_accounts_service.rb', line 5

def execute
   = google_api_client.(gcp_project_id, , )
   = google_api_client.(gcp_project_id, .unique_id)
  google_api_client.(gcp_project_id, .email)

  service_accounts_service.add_for_project(
    environment_name,
    .project_id,
    Gitlab::Json.dump(),
    Gitlab::Json.dump(),
    ProtectedBranch.protected?(project, environment_name) || ProtectedTag.protected?(project, environment_name)
  )

  ServiceResponse.success(message: _('Service account generated successfully'), payload: {
    service_account: ,
    service_account_key: 
  })
end