diff options
author | Douwe Maan <douwe@selenight.nl> | 2016-01-28 16:49:34 +0300 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2016-01-28 16:49:34 +0300 |
commit | 590e237d552a913d72161f0e40743418251f11a8 (patch) | |
tree | 0743722eae0099ac06ac39573e777b5d9a335e5f /lib | |
parent | b636f83e5910d10a954464370efe42cc14a097ba (diff) | |
parent | 9bf47f06ab69a1592cec87825aaaf5bb4adec464 (diff) |
Merge branch 'master' into highlight-blame
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/helpers.rb | 5 | ||||
-rw-r--r-- | lib/ci/api/api.rb | 2 | ||||
-rw-r--r-- | lib/ci/api/builds.rb | 2 | ||||
-rw-r--r-- | lib/ci/api/helpers.rb | 10 | ||||
-rw-r--r-- | lib/ci/api/runners.rb | 1 |
5 files changed, 13 insertions, 7 deletions
diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb index 3f528b9f7c0..9dacf7c1e86 100644 --- a/lib/api/helpers.rb +++ b/lib/api/helpers.rb @@ -153,10 +153,11 @@ module API end def attributes_for_keys(keys, custom_params = nil) + params_hash = custom_params || params attrs = {} keys.each do |key| - if params[key].present? or (params.has_key?(key) and params[key] == false) - attrs[key] = params[key] + if params_hash[key].present? or (params_hash.has_key?(key) and params_hash[key] == false) + attrs[key] = params_hash[key] end end ActionController::Parameters.new(attrs).permit! diff --git a/lib/ci/api/api.rb b/lib/ci/api/api.rb index 5c347e432b4..4e85d2c3c74 100644 --- a/lib/ci/api/api.rb +++ b/lib/ci/api/api.rb @@ -25,7 +25,7 @@ module Ci format :json - helpers Helpers + helpers ::Ci::API::Helpers helpers ::API::Helpers helpers Gitlab::CurrentSettings diff --git a/lib/ci/api/builds.rb b/lib/ci/api/builds.rb index 690bbf97a89..416b0b5f0b4 100644 --- a/lib/ci/api/builds.rb +++ b/lib/ci/api/builds.rb @@ -13,13 +13,13 @@ module Ci post "register" do authenticate_runner! update_runner_last_contact + update_runner_info required_attributes! [:token] not_found! unless current_runner.active? build = Ci::RegisterBuildService.new.execute(current_runner) if build - update_runner_info present build, with: Entities::BuildDetails else not_found! diff --git a/lib/ci/api/helpers.rb b/lib/ci/api/helpers.rb index 1c91204e98c..199d62d9b8a 100644 --- a/lib/ci/api/helpers.rb +++ b/lib/ci/api/helpers.rb @@ -34,10 +34,14 @@ module Ci @runner ||= Runner.find_by_token(params[:token].to_s) end - def update_runner_info + def get_runner_version_from_params return unless params["info"].present? - info = attributes_for_keys(["name", "version", "revision", "platform", "architecture"], params["info"]) - current_runner.update(info) + attributes_for_keys(["name", "version", "revision", "platform", "architecture"], params["info"]) + end + + def update_runner_info + current_runner.assign_attributes(get_runner_version_from_params) + current_runner.save if current_runner.changed? end def max_artifacts_size diff --git a/lib/ci/api/runners.rb b/lib/ci/api/runners.rb index bfc14fe7a6b..192b1d18a51 100644 --- a/lib/ci/api/runners.rb +++ b/lib/ci/api/runners.rb @@ -47,6 +47,7 @@ module Ci return forbidden! unless runner if runner.id + runner.update(get_runner_version_from_params) present runner, with: Entities::Runner else not_found! |