Skip to content

Commit

Permalink
Remove v2 section from / if temporary_enable_v2 == false (#4034)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
jochenehret authored Oct 23, 2024
1 parent 779c9ed commit 2ae7c7e
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 7 deletions.
21 changes: 14 additions & 7 deletions app/controllers/runtime/root_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -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

Expand All @@ -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
2 changes: 2 additions & 0 deletions config/cloud_controller.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions lib/cloud_controller/config_schemas/base/api_schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
12 changes: 12 additions & 0 deletions spec/unit/controllers/runtime/root_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 2ae7c7e

Please sign in to comment.