Class: Ci::JobTokenScope::RemoveProjectService
- Inherits:
-
BaseService
- Object
- BaseService
- Ci::JobTokenScope::RemoveProjectService
- Includes:
- EditScopeValidations
- Defined in:
- app/services/ci/job_token_scope/remove_project_service.rb
Constant Summary
Constants included from EditScopeValidations
EditScopeValidations::TARGET_PROJECT_UNAUTHORIZED_OR_UNFOUND, EditScopeValidations::ValidationError
Instance Attribute Summary
Attributes inherited from BaseService
#current_user, #params, #project
Instance Method Summary collapse
Methods included from EditScopeValidations
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(target_project, direction) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/services/ci/job_token_scope/remove_project_service.rb', line 8 def execute(target_project, direction) validate_edit!(project, target_project, current_user) if project == target_project return ServiceResponse.error(message: "Source project cannot be removed from the job token scope") end link = ::Ci::JobToken::ProjectScopeLink .with_access_direction(direction) .for_source_and_target(project, target_project) unless link return ServiceResponse.error(message: "Target project is not in the job token scope") end if link.destroy ServiceResponse.success else ServiceResponse.error(message: link.errors..to_sentence, payload: { project_link: link }) end rescue EditScopeValidations::ValidationError => e ServiceResponse.error(message: e., reason: :insufficient_permissions) end |