Skip to content

Commit

Permalink
restrict default_app_lifecycle on schema level
Browse files Browse the repository at this point in the history
Co-authored-by: Ralf Pannemans <[email protected]>
  • Loading branch information
pbusko and c0d1ngm0nk3y committed Sep 23, 2024
1 parent 23be252 commit 29d7904
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/cloud_controller/config_schemas/base/api_schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ class ApiSchema < VCAP::Config

internal_route_vip_range: String,

default_app_lifecycle: String,
default_app_lifecycle: enum('buildpack', 'cnb'),
custom_metric_tag_prefix_list: Array,

optional(:cc_service_key_client_name) => String,
Expand Down
3 changes: 2 additions & 1 deletion lib/cloud_controller/config_schemas/base/worker_schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@ class WorkerSchema < VCAP::Config
max_labels_per_resource: Integer,
max_annotations_per_resource: Integer,
internal_route_vip_range: String,
custom_metric_tag_prefix_list: Array
custom_metric_tag_prefix_list: Array,
default_app_lifecycle: enum('buildpack', 'cnb')
}
end
# rubocop:enable Metrics/BlockLength
Expand Down
48 changes: 48 additions & 0 deletions spec/request/buildpacks_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
order_by: 'updated_at',
names: 'foo',
stacks: 'cf',
lifecycle: 'buildpack',
label_selector: 'foo,bar',
guids: 'foo,bar',
created_ats: "#{Time.now.utc.iso8601},#{Time.now.utc.iso8601}",
Expand Down Expand Up @@ -95,6 +96,7 @@
let!(:buildpack1) { VCAP::CloudController::Buildpack.make(stack: stack1.name, position: 1) }
let!(:buildpack2) { VCAP::CloudController::Buildpack.make(stack: stack2.name, position: 3) }
let!(:buildpack3) { VCAP::CloudController::Buildpack.make(stack: stack3.name, position: 2) }
let!(:buildpack4) { VCAP::CloudController::Buildpack.make(stack: stack1.name, position: 1, lifecycle: 'cnb') }

it 'returns a paginated list of buildpacks, sorted by position' do
get '/v3/buildpacks?page=1&per_page=2', nil, headers
Expand Down Expand Up @@ -213,6 +215,52 @@
)
end

it 'returns a list of buildpacks filtered by lifecycle' do
get '/v3/buildpacks?lifecycle=cnb', nil, headers

expect(parsed_response).to be_a_response_like(
{
'pagination' => {
'total_results' => 1,
'total_pages' => 1,
'first' => {
'href' => "#{link_prefix}/v3/buildpacks?lifecycle=cnb&page=1&per_page=50"
},
'last' => {
'href' => "#{link_prefix}/v3/buildpacks?lifecycle=cnb&page=1&per_page=50"
},
'next' => nil,
'previous' => nil
},
'resources' => [
{
'guid' => buildpack4.guid,
'lifecycle' => 'cnb',
'created_at' => iso8601,
'updated_at' => iso8601,
'name' => buildpack4.name,
'state' => buildpack4.state,
'filename' => buildpack4.filename,
'stack' => buildpack4.stack,
'position' => 1,
'enabled' => true,
'locked' => false,
'metadata' => { 'labels' => {}, 'annotations' => {} },
'links' => {
'self' => {
'href' => "#{link_prefix}/v3/buildpacks/#{buildpack4.guid}"
},
'upload' => {
'href' => "#{link_prefix}/v3/buildpacks/#{buildpack4.guid}/upload",
'method' => 'POST'
}
}
}
]
}
)
end

it 'orders by position' do
get "/v3/buildpacks?names=#{buildpack1.name},#{buildpack3.name}&order_by=-position", nil, headers

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ module VCAP::CloudController
expect(AppLifecycleProvider.provide_for_create(message)).to be_a(AppBuildpackLifecycle)
end
end

context 'default_app_lifecycle is set to cnb' do
before do
TestConfig.override(default_app_lifecycle: 'cnb')
end

it 'returns a AppCNBLifecycle' do
expect(AppLifecycleProvider.provide_for_create(message)).to be_a(AppCNBLifecycle)
end
end
end
end

Expand Down

0 comments on commit 29d7904

Please sign in to comment.