Skip to content

Commit ca076ad

Browse files
pbuskoc0d1ngm0nk3y
authored andcommitted
restrict default_app_lifecycle on schema level
Co-authored-by: Ralf Pannemans <[email protected]>
1 parent 1da5584 commit ca076ad

File tree

4 files changed

+61
-2
lines changed

4 files changed

+61
-2
lines changed

Diff for: lib/cloud_controller/config_schemas/base/api_schema.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ class ApiSchema < VCAP::Config
363363

364364
internal_route_vip_range: String,
365365

366-
default_app_lifecycle: String,
366+
default_app_lifecycle: enum('buildpack', 'cnb'),
367367
custom_metric_tag_prefix_list: Array,
368368

369369
optional(:cc_service_key_client_name) => String,

Diff for: lib/cloud_controller/config_schemas/base/worker_schema.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,8 @@ class WorkerSchema < VCAP::Config
177177
max_labels_per_resource: Integer,
178178
max_annotations_per_resource: Integer,
179179
internal_route_vip_range: String,
180-
custom_metric_tag_prefix_list: Array
180+
custom_metric_tag_prefix_list: Array,
181+
default_app_lifecycle: enum('buildpack', 'cnb')
181182
}
182183
end
183184
# rubocop:enable Metrics/BlockLength

Diff for: spec/request/buildpacks_spec.rb

+48
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
order_by: 'updated_at',
2929
names: 'foo',
3030
stacks: 'cf',
31+
lifecycle: 'buildpack',
3132
label_selector: 'foo,bar',
3233
guids: 'foo,bar',
3334
created_ats: "#{Time.now.utc.iso8601},#{Time.now.utc.iso8601}",
@@ -95,6 +96,7 @@
9596
let!(:buildpack1) { VCAP::CloudController::Buildpack.make(stack: stack1.name, position: 1) }
9697
let!(:buildpack2) { VCAP::CloudController::Buildpack.make(stack: stack2.name, position: 3) }
9798
let!(:buildpack3) { VCAP::CloudController::Buildpack.make(stack: stack3.name, position: 2) }
99+
let!(:buildpack4) { VCAP::CloudController::Buildpack.make(stack: stack1.name, position: 1, lifecycle: 'cnb') }
98100

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

218+
it 'returns a list of buildpacks filtered by lifecycle' do
219+
get '/v3/buildpacks?lifecycle=cnb', nil, headers
220+
221+
expect(parsed_response).to be_a_response_like(
222+
{
223+
'pagination' => {
224+
'total_results' => 1,
225+
'total_pages' => 1,
226+
'first' => {
227+
'href' => "#{link_prefix}/v3/buildpacks?lifecycle=cnb&page=1&per_page=50"
228+
},
229+
'last' => {
230+
'href' => "#{link_prefix}/v3/buildpacks?lifecycle=cnb&page=1&per_page=50"
231+
},
232+
'next' => nil,
233+
'previous' => nil
234+
},
235+
'resources' => [
236+
{
237+
'guid' => buildpack4.guid,
238+
'lifecycle' => 'cnb',
239+
'created_at' => iso8601,
240+
'updated_at' => iso8601,
241+
'name' => buildpack4.name,
242+
'state' => buildpack4.state,
243+
'filename' => buildpack4.filename,
244+
'stack' => buildpack4.stack,
245+
'position' => 1,
246+
'enabled' => true,
247+
'locked' => false,
248+
'metadata' => { 'labels' => {}, 'annotations' => {} },
249+
'links' => {
250+
'self' => {
251+
'href' => "#{link_prefix}/v3/buildpacks/#{buildpack4.guid}"
252+
},
253+
'upload' => {
254+
'href' => "#{link_prefix}/v3/buildpacks/#{buildpack4.guid}/upload",
255+
'method' => 'POST'
256+
}
257+
}
258+
}
259+
]
260+
}
261+
)
262+
end
263+
216264
it 'orders by position' do
217265
get "/v3/buildpacks?names=#{buildpack1.name},#{buildpack3.name}&order_by=-position", nil, headers
218266

Diff for: spec/unit/lib/cloud_controller/diego/lifecycles/app_lifecycle_provider_spec.rb

+10
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,16 @@ module VCAP::CloudController
3737
expect(AppLifecycleProvider.provide_for_create(message)).to be_a(AppBuildpackLifecycle)
3838
end
3939
end
40+
41+
context 'default_app_lifecycle is set to cnb' do
42+
before do
43+
TestConfig.override(default_app_lifecycle: 'cnb')
44+
end
45+
46+
it 'returns a AppCNBLifecycle' do
47+
expect(AppLifecycleProvider.provide_for_create(message)).to be_a(AppCNBLifecycle)
48+
end
49+
end
4050
end
4151
end
4252

0 commit comments

Comments
 (0)