Class: GoogleCloud::ServiceAccountsService
- Inherits:
-
BaseService
- Object
- BaseService
- BaseService
- GoogleCloud::ServiceAccountsService
- Defined in:
- app/services/google_cloud/service_accounts_service.rb
Overview
This service deals with GCP Service Accounts in GitLab
Instance Attribute Summary
Attributes inherited from BaseService
#current_user, #params, #project
Instance Method Summary collapse
- #add_for_project(ref, gcp_project_id, service_account, service_account_key, is_protected) ⇒ Object
-
#find_for_project ⇒ Object
Find GCP Service Accounts in a GitLab project.
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
#add_for_project(ref, gcp_project_id, service_account, service_account_key, is_protected) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'app/services/google_cloud/service_accounts_service.rb', line 30 def add_for_project(ref, gcp_project_id, service_account, service_account_key, is_protected) create_or_replace_project_vars( ref, 'GCP_PROJECT_ID', gcp_project_id, is_protected ) create_or_replace_project_vars( ref, 'GCP_SERVICE_ACCOUNT', service_account, is_protected ) create_or_replace_project_vars( ref, 'GCP_SERVICE_ACCOUNT_KEY', service_account_key, is_protected ) end |
#find_for_project ⇒ Object
Find GCP Service Accounts in a GitLab project
This method looks up GitLab project’s CI vars and returns Google Cloud Service Accounts combinations aligning GitLab project and ref to GCP projects
19 20 21 22 23 24 25 26 27 28 |
# File 'app/services/google_cloud/service_accounts_service.rb', line 19 def find_for_project group_vars_by_environment(GCP_KEYS).map do |environment_scope, value| { ref: environment_scope, gcp_project: value['GCP_PROJECT_ID'], service_account_exists: value['GCP_SERVICE_ACCOUNT'].present?, service_account_key_exists: value['GCP_SERVICE_ACCOUNT_KEY'].present? } end end |