diff options
author | Kamil Trzciński <ayufan@ayufan.eu> | 2018-02-28 16:53:53 +0300 |
---|---|---|
committer | Kamil Trzciński <ayufan@ayufan.eu> | 2018-02-28 16:53:53 +0300 |
commit | 2aa647ec07edd0caaad9c2b56f8ab24bfea4e6f6 (patch) | |
tree | ee2542cc8fc9f5342a4f39daf4ca33215bf0c97d /lib | |
parent | 573738ee6c08d018783c433f3ace376ead674d3c (diff) | |
parent | 8a49b1dfed8a7f74eb236465f4ae90c28aab406f (diff) |
Merge branch '43489-display-runner-ip' into 'master'
Resolve "Display IP Address Of Runner On Runner Page"
Closes #43489
See merge request gitlab-org/gitlab-ce!17286
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/helpers/runner.rb | 18 | ||||
-rw-r--r-- | lib/api/runner.rb | 4 |
2 files changed, 14 insertions, 8 deletions
diff --git a/lib/api/helpers/runner.rb b/lib/api/helpers/runner.rb index fbe30192a16..35ac0b4cbca 100644 --- a/lib/api/helpers/runner.rb +++ b/lib/api/helpers/runner.rb @@ -9,16 +9,22 @@ module API Gitlab::CurrentSettings.runners_registration_token) end - def get_runner_version_from_params - return unless params['info'].present? + def authenticate_runner! + forbidden! unless current_runner - attributes_for_keys(%w(name version revision platform architecture), params['info']) + current_runner + .update_cached_info(get_runner_details_from_request) end - def authenticate_runner! - forbidden! unless current_runner + def get_runner_details_from_request + return get_runner_ip unless params['info'].present? + + attributes_for_keys(%w(name version revision platform architecture), params['info']) + .merge(get_runner_ip) + end - current_runner.update_cached_info(get_runner_version_from_params) + def get_runner_ip + { ip_address: request.ip } end def current_runner diff --git a/lib/api/runner.rb b/lib/api/runner.rb index 5469cba69a6..91cdc564002 100644 --- a/lib/api/runner.rb +++ b/lib/api/runner.rb @@ -16,7 +16,8 @@ module API optional :tag_list, type: Array[String], desc: %q(List of Runner's tags) end post '/' do - attributes = attributes_for_keys [:description, :locked, :run_untagged, :tag_list] + attributes = attributes_for_keys([:description, :locked, :run_untagged, :tag_list]) + .merge(get_runner_details_from_request) runner = if runner_registration_token_valid? @@ -30,7 +31,6 @@ module API return forbidden! unless runner if runner.id - runner.update(get_runner_version_from_params) present runner, with: Entities::RunnerRegistrationDetails else not_found! |