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>2020-12-17 14:59:07 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-12-17 14:59:07 +0300
commit8b573c94895dc0ac0e1d9d59cf3e8745e8b539ca (patch)
tree544930fb309b30317ae9797a9683768705d664c4 /app/services/clusters/aws/authorize_role_service.rb
parent4b1de649d0168371549608993deac953eb692019 (diff)
Add latest changes from gitlab-org/gitlab@13-7-stable-eev13.7.0-rc42
Diffstat (limited to 'app/services/clusters/aws/authorize_role_service.rb')
-rw-r--r--app/services/clusters/aws/authorize_role_service.rb24
1 files changed, 23 insertions, 1 deletions
diff --git a/app/services/clusters/aws/authorize_role_service.rb b/app/services/clusters/aws/authorize_role_service.rb
index 188c4aebc5f..7ca20289bf7 100644
--- a/app/services/clusters/aws/authorize_role_service.rb
+++ b/app/services/clusters/aws/authorize_role_service.rb
@@ -29,7 +29,7 @@ module Clusters
rescue *ERRORS => e
Gitlab::ErrorTracking.track_exception(e)
- Response.new(:unprocessable_entity, {})
+ Response.new(:unprocessable_entity, response_details(e))
end
private
@@ -47,6 +47,28 @@ module Clusters
def credentials
Clusters::Aws::FetchCredentialsService.new(role).execute
end
+
+ def response_details(exception)
+ message =
+ case exception
+ when ::Aws::STS::Errors::AccessDenied
+ _("Access denied: %{error}") % { error: exception.message }
+ when ::Aws::STS::Errors::ServiceError
+ _("AWS service error: %{error}") % { error: exception.message }
+ when ActiveRecord::RecordNotFound
+ _("Error: Unable to find AWS role for current user")
+ when ActiveRecord::RecordInvalid
+ exception.message
+ when Clusters::Aws::FetchCredentialsService::MissingRoleError
+ _("Error: No AWS provision role found for user")
+ when ::Aws::Errors::MissingCredentialsError
+ _("Error: No AWS credentials were supplied")
+ else
+ _('An error occurred while authorizing your role')
+ end
+
+ { message: message }.compact
+ end
end
end
end