Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove v2 section from / if temporary_enable_v2 == false #4034

Merged
merged 2 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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