Skip to content

Commit 2ae7c7e

Browse files
authored
Remove v2 section from / if temporary_enable_v2 == false (#4034)
* Remove v2 section from / if temporary_enable_v2 == false * use config paraemter "temporary_enable_v2" from capi-release (default: true) * if false, remove "cloud_controller_v2" section from root endpoint * Fix Rubocop findings
1 parent 779c9ed commit 2ae7c7e

File tree

4 files changed

+30
-7
lines changed

4 files changed

+30
-7
lines changed

app/controllers/runtime/root_controller.rb

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,6 @@ def read
1515
href: api_url_builder.build_url
1616
},
1717

18-
cloud_controller_v2: {
19-
href: api_url_builder.build_url(path: '/v2'),
20-
meta: {
21-
version: VCAP::CloudController::Constants::API_VERSION
22-
}
23-
},
24-
2518
cloud_controller_v3: {
2619
href: api_url_builder.build_url(path: '/v3'),
2720
meta: {
@@ -71,6 +64,8 @@ def read
7164
}
7265
}
7366

67+
response[:links].merge!(cloud_controller_v2(api_url_builder)) if config.get(:temporary_enable_v2)
68+
7469
[200, Oj.dump(response, mode: :compat)]
7570
end
7671

@@ -91,5 +86,17 @@ def routing_link
9186

9287
{ href: config.get(:routing_api, :url) }
9388
end
89+
90+
def cloud_controller_v2(api_url_builder)
91+
{
92+
cloud_controller_v2:
93+
{
94+
href: api_url_builder.build_url(path: '/v2'),
95+
meta: {
96+
version: VCAP::CloudController::Constants::API_VERSION
97+
}
98+
}
99+
}
100+
end
94101
end
95102
end

config/cloud_controller.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,8 @@ rate_limiter_v2_api:
279279
global_admin_limit: 20000
280280
reset_interval_in_minutes: 60
281281

282+
temporary_enable_v2: true
283+
282284
max_concurrent_service_broker_requests: 0
283285

284286
diego:

lib/cloud_controller/config_schemas/base/api_schema.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,8 @@ class ApiSchema < VCAP::Config
322322
reset_interval_in_minutes: Integer
323323
},
324324

325+
optional(:temporary_enable_v2) => bool,
326+
325327
allow_app_ssh_access: bool,
326328

327329
optional(:external_host) => String,

spec/unit/controllers/runtime/root_controller_spec.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,18 @@ module VCAP::CloudController
2626
)
2727
end
2828

29+
context 'temporary_enable_v2 is false' do
30+
before do
31+
TestConfig.override(temporary_enable_v2: false)
32+
end
33+
34+
it 'returns no cloud controller v2 link with metadata' do
35+
get '/'
36+
hash = Oj.load(last_response.body)
37+
expect(hash['links']['cloud_controller_v2']).to be_nil
38+
end
39+
end
40+
2941
it 'returns a cloud controller v3 link with metadata' do
3042
get '/'
3143
hash = Oj.load(last_response.body)

0 commit comments

Comments
 (0)