summaryrefslogtreecommitdiff
path: root/lib/api/deploy_tokens.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-04-01 12:08:00 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-04-01 12:08:00 +0000
commit1a0d6dbdc2ac3047f4953a359ef27ba6e26074ae (patch)
treeddb78a8a0d1350dc767f049a21e0f7d37edaa82c /lib/api/deploy_tokens.rb
parentb11f7057d067885619ee3e513751f180b2e8ad85 (diff)
downloadgitlab-ce-1a0d6dbdc2ac3047f4953a359ef27ba6e26074ae.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/api/deploy_tokens.rb')
-rw-r--r--lib/api/deploy_tokens.rb16
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/api/deploy_tokens.rb b/lib/api/deploy_tokens.rb
index a637bfcb180..fb4c4265aef 100644
--- a/lib/api/deploy_tokens.rb
+++ b/lib/api/deploy_tokens.rb
@@ -65,11 +65,15 @@ module API
post ':id/deploy_tokens' do
authorize!(:create_deploy_token, user_project)
- deploy_token = ::Projects::DeployTokens::CreateService.new(
+ result = ::Projects::DeployTokens::CreateService.new(
user_project, current_user, scope_params.merge(declared(params, include_missing: false, include_parent_namespaces: false))
).execute
- present deploy_token, with: Entities::DeployTokenWithToken
+ if result[:status] == :success
+ present result[:deploy_token], with: Entities::DeployTokenWithToken
+ else
+ render_api_error!(result[:message], result[:http_status])
+ end
end
desc 'Delete a project deploy token' do
@@ -126,11 +130,15 @@ module API
post ':id/deploy_tokens' do
authorize!(:create_deploy_token, user_group)
- deploy_token = ::Groups::DeployTokens::CreateService.new(
+ result = ::Groups::DeployTokens::CreateService.new(
user_group, current_user, scope_params.merge(declared(params, include_missing: false, include_parent_namespaces: false))
).execute
- present deploy_token, with: Entities::DeployTokenWithToken
+ if result[:status] == :success
+ present result[:deploy_token], with: Entities::DeployTokenWithToken
+ else
+ render_api_error!(result[:message], result[:http_status])
+ end
end
desc 'Delete a group deploy token' do