Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-12-14 18:07:56 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-12-14 18:07:56 +0300
commit016af097cb1fa872fdc28a786d16315e55cd2701 (patch)
tree76f97f90a8048685efb3eb0c543b3a75d99be6ee /app/services/deployments
parent00b8ecb72c9f77d864aff3572f028613f45af03c (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/services/deployments')
-rw-r--r--app/services/deployments/create_service.rb17
-rw-r--r--app/services/deployments/update_service.rb17
2 files changed, 10 insertions, 24 deletions
diff --git a/app/services/deployments/create_service.rb b/app/services/deployments/create_service.rb
index 89e3f7c8b83..7355747d778 100644
--- a/app/services/deployments/create_service.rb
+++ b/app/services/deployments/create_service.rb
@@ -11,15 +11,17 @@ module Deployments
end
def execute
- create_deployment.tap do |deployment|
- AfterCreateService.new(deployment).execute if deployment.persisted?
+ environment.deployments.build(deployment_attributes).tap do |deployment|
+ # Deployment#change_status already saves the model, so we only need to
+ # call #save ourselves if no status is provided.
+ if (status = params[:status])
+ deployment.update_status(status)
+ else
+ deployment.save
+ end
end
end
- def create_deployment
- environment.deployments.create(deployment_attributes)
- end
-
def deployment_attributes
# We use explicit parameters here so we never by accident allow parameters
# to be set that one should not be able to set (e.g. the row ID).
@@ -31,8 +33,7 @@ module Deployments
tag: params[:tag],
sha: params[:sha],
user: current_user,
- on_stop: params[:on_stop],
- status: params[:status]
+ on_stop: params[:on_stop]
}
end
end
diff --git a/app/services/deployments/update_service.rb b/app/services/deployments/update_service.rb
index 97b233f16a7..b8f8740c9b9 100644
--- a/app/services/deployments/update_service.rb
+++ b/app/services/deployments/update_service.rb
@@ -10,22 +10,7 @@ module Deployments
end
def execute
- # A regular update() does not trigger the state machine transitions, which
- # we need to ensure merge requests are linked when changing the status to
- # success. To work around this we use this case statment, using the right
- # event methods to trigger the transition hooks.
- case params[:status]
- when 'running'
- deployment.run
- when 'success'
- deployment.succeed
- when 'failed'
- deployment.drop
- when 'canceled'
- deployment.cancel
- else
- false
- end
+ deployment.update_status(params[:status])
end
end
end