Class: Ci::Deployments::DestroyService
- Inherits:
-
BaseService
- Object
- BaseService
- Ci::Deployments::DestroyService
- Defined in:
- app/services/ci/deployments/destroy_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(deployment) ⇒ Object
6 7 8 9 10 11 12 13 14 15 |
# File 'app/services/ci/deployments/destroy_service.rb', line 6 def execute(deployment) raise Gitlab::Access::AccessDeniedError unless can?(current_user, :destroy_deployment, deployment) return ServiceResponse.error(message: 'Cannot destroy running deployment') if deployment&.running? return ServiceResponse.error(message: 'Deployment currently deployed to environment') if deployment&.last? project.destroy_deployment_by_id(deployment) ServiceResponse.success(message: 'Deployment destroyed') end |