Class: DependencyProxy::RequestTokenService
- Inherits:
-
BaseService
- Object
- BaseService
- BaseService
- DependencyProxy::RequestTokenService
- Defined in:
- app/services/dependency_proxy/request_token_service.rb
Constant Summary
Constants inherited from BaseService
BaseService::UnauthorizedError
Instance Attribute Summary
Attributes inherited from BaseService
#current_user, #params, #project
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(image:, dependency_proxy_setting:) ⇒ RequestTokenService
constructor
A new instance of RequestTokenService.
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
#initialize(image:, dependency_proxy_setting:) ⇒ RequestTokenService
Returns a new instance of RequestTokenService.
5 6 7 8 |
# File 'app/services/dependency_proxy/request_token_service.rb', line 5 def initialize(image:, dependency_proxy_setting:) @image = image @dependency_proxy_setting = dependency_proxy_setting end |
Instance Method Details
#execute ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/services/dependency_proxy/request_token_service.rb', line 10 def execute response = Gitlab::HTTP.get( auth_url, headers: @dependency_proxy_setting&. || {}, follow_redirects: true ) if response.success? success(token: Gitlab::Json.parse(response.body)['token']) else error('Expected 200 response code for an access token', response.code) end rescue Timeout::Error => exception error(exception., 599) rescue JSON::ParserError error('Failed to parse a response body for an access token', 500) end |