Skip to content

Commit

Permalink
Add OSBAPI version to /v3/info
Browse files Browse the repository at this point in the history
  • Loading branch information
WeiQuan0605 committed Jan 8, 2025
1 parent 36682b3 commit aaf5206
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
10 changes: 9 additions & 1 deletion app/controllers/v3/info_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ def v3_info
info.version = config.get(:info, :version) || 0
info.support_address = config.get(:info, :support_address) || ''

osbapi_version_file = Rails.root.join('config/osbapi_version').to_s
if File.exist?(osbapi_version_file)
info.osbapi_version = File.read(osbapi_version_file).strip
else
info.osbapi_version = ''
Rails.logger.warn("OSBAPI version file not found at #{osbapi_version_file}")
end

render status: :ok, json: VCAP::CloudController::Presenters::V3::InfoPresenter.new(info)
end

Expand All @@ -29,5 +37,5 @@ def show_usage_summary
end

class Info
attr_accessor :build, :min_cli_version, :min_recommended_cli_version, :custom, :description, :name, :version, :support_address
attr_accessor :build, :min_cli_version, :min_recommended_cli_version, :custom, :description, :name, :version, :support_address, :osbapi_version
end
1 change: 1 addition & 0 deletions app/presenters/v3/info_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def to_hash
description: info.description,
name: info.name,
version: info.version,
osbapi_version: info.osbapi_version,
links: {
self: { href: build_self },
support: { href: info.support_address }
Expand Down
1 change: 1 addition & 0 deletions spec/request/info_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
description: '',
name: '',
version: 0,
osbapi_version: 0,
links: {
self: { href: "#{link_prefix}/v3/info" },
support: { href: '' }
Expand Down

0 comments on commit aaf5206

Please sign in to comment.