diff options
author | Valery Sizov <vsv2711@gmail.com> | 2015-05-12 17:41:12 +0300 |
---|---|---|
committer | Valery Sizov <vsv2711@gmail.com> | 2015-05-12 19:47:41 +0300 |
commit | e93b0a4ccb0b13d88ff833525fea3683f8a4de30 (patch) | |
tree | 5865bb56132c5e1cb55aa43044aecf122a5fc441 /lib | |
parent | 5b3450f9b4241feee5fa69f78366392015ab25f1 (diff) | |
download | gitlab-ci-save_info_from_runner.tar.gz |
storing runner infosave_info_from_runner
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/builds.rb | 1 | ||||
-rw-r--r-- | lib/api/helpers.rb | 11 |
2 files changed, 10 insertions, 2 deletions
diff --git a/lib/api/builds.rb b/lib/api/builds.rb index 0f9c2a9..67b73db 100644 --- a/lib/api/builds.rb +++ b/lib/api/builds.rb @@ -18,6 +18,7 @@ module API build = RegisterBuildService.new.execute(current_runner) if build + update_runner_info present build, with: Entities::Build else not_found! diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb index d09af26..215792a 100644 --- a/lib/api/helpers.rb +++ b/lib/api/helpers.rb @@ -39,6 +39,12 @@ module API end end + def update_runner_info + return unless params["info"].present? + info = attributes_for_keys(["name", "version", "revision", "platform", "architecture"], params["info"]) + current_runner.update(info) + end + # Checks the occurrences of required attributes, each attribute must be present in the params hash # or a Bad Request error is invoked. # @@ -50,10 +56,11 @@ module API end end - def attributes_for_keys(keys) + def attributes_for_keys(keys, custom_params = nil) + params_hash = custom_params || params attrs = {} keys.each do |key| - attrs[key] = params[key] if params[key].present? + attrs[key] = params_hash[key] if params_hash[key].present? end attrs end |