From b7d6bb9763ce0c682fae787c452103102624da26 Mon Sep 17 00:00:00 2001 From: Tomasz Maczukin Date: Mon, 5 Jun 2017 16:39:45 +0200 Subject: Ensure that old API v1 generates still the same output --- lib/ci/api/entities.rb | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'lib/ci') diff --git a/lib/ci/api/entities.rb b/lib/ci/api/entities.rb index 792ff628b09..6733d1a33aa 100644 --- a/lib/ci/api/entities.rb +++ b/lib/ci/api/entities.rb @@ -45,7 +45,25 @@ module Ci expose :artifacts_expire_at, if: ->(build, _) { build.artifacts? } expose :options do |model| - model.options + options = model.options + + # This part ensures that output of old API is still the same after adding support + # for extended docker configuration options, used by new API + # + # I'm leaving this here, not in the model, because it should be removed at the same time + # when old API will be removed (planned for August 2017). + options[:image] = options[:image][:name] if options[:image].present? && options[:image].is_a?(Hash) + if options[:services].present? + options[:services].map! do |service| + if service.is_a?(Hash) + service[:name] + else + service + end + end + end + + options end expose :timeout do |model| -- cgit v1.2.3