diff --git a/app/controllers/runtime/root_controller.rb b/app/controllers/runtime/root_controller.rb index 789e519e08d..d6bc9beebb2 100644 --- a/app/controllers/runtime/root_controller.rb +++ b/app/controllers/runtime/root_controller.rb @@ -15,13 +15,6 @@ def read href: api_url_builder.build_url }, - cloud_controller_v2: { - href: api_url_builder.build_url(path: '/v2'), - meta: { - version: VCAP::CloudController::Constants::API_VERSION - } - }, - cloud_controller_v3: { href: api_url_builder.build_url(path: '/v3'), meta: { @@ -71,6 +64,8 @@ def read } } + response[:links].merge!(cloud_controller_v2(api_url_builder)) if config.get(:temporary_enable_v2) + [200, Oj.dump(response, mode: :compat)] end @@ -91,5 +86,17 @@ def routing_link { href: config.get(:routing_api, :url) } end + + def cloud_controller_v2(api_url_builder) + { + cloud_controller_v2: + { + href: api_url_builder.build_url(path: '/v2'), + meta: { + version: VCAP::CloudController::Constants::API_VERSION + } + } + } + end end end diff --git a/config/cloud_controller.yml b/config/cloud_controller.yml index 08d6a4c07dc..9c1e0a819fc 100644 --- a/config/cloud_controller.yml +++ b/config/cloud_controller.yml @@ -279,6 +279,8 @@ rate_limiter_v2_api: global_admin_limit: 20000 reset_interval_in_minutes: 60 +temporary_enable_v2: true + max_concurrent_service_broker_requests: 0 diego: diff --git a/lib/cloud_controller/config_schemas/base/api_schema.rb b/lib/cloud_controller/config_schemas/base/api_schema.rb index ff381aee45c..6bf5e263d89 100644 --- a/lib/cloud_controller/config_schemas/base/api_schema.rb +++ b/lib/cloud_controller/config_schemas/base/api_schema.rb @@ -322,6 +322,8 @@ class ApiSchema < VCAP::Config reset_interval_in_minutes: Integer }, + optional(:temporary_enable_v2) => bool, + allow_app_ssh_access: bool, optional(:external_host) => String, diff --git a/spec/unit/controllers/runtime/root_controller_spec.rb b/spec/unit/controllers/runtime/root_controller_spec.rb index e9417caf4bf..e3a55035126 100644 --- a/spec/unit/controllers/runtime/root_controller_spec.rb +++ b/spec/unit/controllers/runtime/root_controller_spec.rb @@ -26,6 +26,18 @@ module VCAP::CloudController ) end + context 'temporary_enable_v2 is false' do + before do + TestConfig.override(temporary_enable_v2: false) + end + + it 'returns no cloud controller v2 link with metadata' do + get '/' + hash = Oj.load(last_response.body) + expect(hash['links']['cloud_controller_v2']).to be_nil + end + end + it 'returns a cloud controller v3 link with metadata' do get '/' hash = Oj.load(last_response.body)