Class: Deployments::UpdateEnvironmentService
- Inherits:
-
Object
- Object
- Deployments::UpdateEnvironmentService
- Defined in:
- app/services/deployments/update_environment_service.rb
Constant Summary collapse
- EnvironmentUpdateFailure =
Class.new(StandardError)
Instance Attribute Summary collapse
-
#deployable ⇒ Object
readonly
Returns the value of attribute deployable.
-
#deployment ⇒ Object
readonly
Returns the value of attribute deployment.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(deployment) ⇒ UpdateEnvironmentService
constructor
A new instance of UpdateEnvironmentService.
- #update_environment(deployment) ⇒ Object
Constructor Details
#initialize(deployment) ⇒ UpdateEnvironmentService
Returns a new instance of UpdateEnvironmentService.
14 15 16 17 |
# File 'app/services/deployments/update_environment_service.rb', line 14 def initialize(deployment) @deployment = deployment @deployable = deployment.deployable end |
Instance Attribute Details
#deployable ⇒ Object (readonly)
Returns the value of attribute deployable.
6 7 8 |
# File 'app/services/deployments/update_environment_service.rb', line 6 def deployable @deployable end |
#deployment ⇒ Object (readonly)
Returns the value of attribute deployment.
5 6 7 |
# File 'app/services/deployments/update_environment_service.rb', line 5 def deployment @deployment end |
Instance Method Details
#execute ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'app/services/deployments/update_environment_service.rb', line 19 def execute deployment.create_ref deployment.invalidate_cache update_environment(deployment) deployment end |
#update_environment(deployment) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'app/services/deployments/update_environment_service.rb', line 28 def update_environment(deployment) ApplicationRecord.transaction do # Renew attributes at update renew_external_url renew_auto_stop_in renew_deployment_tier environment.fire_state_event(action) if environment.save deployment.update_merge_request_metrics! unless environment.stopped? else # If there is a validation error on environment update, such as # the external URL is malformed, the error message is recorded for debugging purpose. # We should surface the error message to users for letting them to take an action. # See https://gitlab.com/gitlab-org/gitlab/-/issues/21182. Gitlab::ErrorTracking.track_exception( EnvironmentUpdateFailure.new, project_id: deployment.project_id, environment_id: environment.id, reason: environment.errors..to_sentence) end end end |