Skip to content

Commit 0c1c5c8

Browse files
committed
Remove default buildpacks filter and change default sort to 'lifecycle'
* also add missing docs
1 parent 4f36879 commit 0c1c5c8

File tree

14 files changed

+488
-26
lines changed

14 files changed

+488
-26
lines changed

app/fetchers/buildpack_list_fetcher.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ def filter(message, dataset)
1919
dataset = dataset.where(name: message.names) if message.requested?(:names)
2020

2121
dataset = NullFilterQueryGenerator.add_filter(dataset, :stack, message.stacks) if message.requested?(:stacks)
22-
dataset = dataset.where(lifecycle: message.requested?(:lifecycle) ? message.lifecycle : Config.config.get(:default_app_lifecycle))
22+
23+
dataset = dataset.where(lifecycle: message.lifecycle) if message.requested?(:lifecycle)
2324

2425
if message.requested?(:label_selector)
2526
dataset = LabelSelectorQueryGenerator.add_selector_queries(

app/messages/buildpacks_list_message.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ class BuildpacksListMessage < MetadataListMessage
2121

2222
def initialize(params={})
2323
super
24-
pagination_options.default_order_by = :position
24+
pagination_options.default_order_by = :lifecycle
25+
pagination_options.secondary_default_order_by = :position
2526
end
2627

2728
def self.from_params(params)
@@ -33,7 +34,7 @@ def to_param_hash
3334
end
3435

3536
def valid_order_by_values
36-
super << :position
37+
super + %i[position lifecycle]
3738
end
3839
end
3940

docs/v3/source/includes/api_resources/_buildpacks.erb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"filename": null,
99
"stack": "windows64",
1010
"position": 42,
11+
"lifecycle": "buildpack",
1112
"enabled": true,
1213
"locked": false,
1314
"metadata": {
@@ -52,6 +53,7 @@
5253
"filename": null,
5354
"stack": "my-stack",
5455
"position": 1,
56+
"lifecycle": "cnb",
5557
"enabled": true,
5658
"locked": false,
5759
"metadata": {

docs/v3/source/includes/resources/buildpacks/_create.md.erb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ Name | Type | Description
4444
----------- | -------- | ----------------------------------------------------------------------------- | -------
4545
**stack** | _string_ | The name of the stack that the buildpack will use | null
4646
**position** | _integer_ | The order in which the buildpacks are checked during buildpack auto-detection | 1
47+
**lifecycle**| _string_ | The version of buildpack the buildpack will use. `buildpack` indicates [Classic Buildpacks](https://docs.cloudfoundry.org/buildpacks/classic.html). `cnb` indicates [Cloud Native Buildpacks](https://docs.cloudfoundry.org/buildpacks/cnb/) | buildpack
4748
**enabled** | _boolean_ | Whether or not the buildpack will be used for staging | true
4849
**locked** | _boolean_ | Whether or not the buildpack is locked to prevent updating the bits | false
4950
**metadata.labels** | [_label object_](#labels) | Labels applied to the buildpack

docs/v3/source/includes/resources/buildpacks/_list.md.erb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ Name | Type | Description
3434
**per_page** | _integer_ | Number of results per page; <br>valid values are 1 through 5000
3535
**names** | _list of strings_ | Comma-delimited list of buildpack names to filter by
3636
**stacks**| _list of strings_ | Comma-delimited list of stack names to filter by
37-
**order_by** | _string_ | Value to sort by; defaults to ascending. Prepend with `-` to sort descending. <br>Valid values are `created_at`, `updated_at`, and `position`
37+
**lifecycle**| _string_ | Type of buildpack. Valid values are `buildpack` and `cnb`
38+
**order_by** | _string_ | Value to sort by; defaults to ascending. Prepend with `-` to sort descending. <br>Valid values are `created_at`, `updated_at`, `lifecycle`, and `position`
3839
**label_selector** | _string_ | A query string containing a list of [label selector](#labels-and-selectors) requirements
3940
**created_ats** | _[timestamp](#timestamps)_ | Timestamp to filter by. When filtering on equality, several comma-delimited timestamps may be passed. Also supports filtering with [relational operators](#relational-operators)
4041
**updated_ats** | _[timestamp](#timestamps)_ | Timestamp to filter by. When filtering on equality, several comma-delimited timestamps may be passed. Also supports filtering with [relational operators](#relational-operators)

docs/v3/source/includes/resources/buildpacks/_object.md.erb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ Name | Type | Description
1515
**updated_at** | _[timestamp](#timestamps)_ | The time with zone when the object was last updated
1616
**name** | _string_ | The name of the buildpack; to be used by app buildpack field (only alphanumeric characters)
1717
**state** | _string_ | The state of the buildpack; valid states are: `AWAITING_UPLOAD`, `READY`
18-
**stack** | _string_ | The name of the stack that the buildpack will use
18+
**stack** | _string_ | The name of the stack that the buildpack uses
19+
**lifecycle** | _string_ | The version of buildpacks the buildpack uses. `buildpack` indicates [Classic Buildpacks](https://docs.cloudfoundry.org/buildpacks/classic.html). `cnb` indicates [Cloud Native Buildpacks](https://docs.cloudfoundry.org/buildpacks/cnb/)
1920
**filename** | _string_ | The filename of the buildpack
2021
**position** | _integer_ | The order in which the buildpacks are checked during buildpack auto-detection
2122
**enabled** | _boolean_ | Whether or not the buildpack can be used for staging

lib/cloud_controller/paging/pagination_options.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class PaginationOptions
1212
DIRECTION_DEFAULT = 'asc'.freeze
1313
VALID_DIRECTIONS = %w[asc desc].freeze
1414

15-
attr_writer :order_by, :order_direction, :default_order_by
15+
attr_writer :order_by, :order_direction, :default_order_by, :secondary_default_order_by
1616
attr_accessor :page, :per_page
1717

1818
def initialize(params)
@@ -38,6 +38,12 @@ def order_direction
3838
@order_direction || DIRECTION_DEFAULT
3939
end
4040

41+
def secondary_order_by
42+
return if @order_by && @order_by.to_s != default_order_by.to_s
43+
44+
@secondary_default_order_by
45+
end
46+
4147
def keys
4248
%i[page per_page order_by order_direction]
4349
end

lib/cloud_controller/paging/sequel_paginator.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ def get_page(dataset, pagination_options)
1313
order_type = Sequel.send(order_direction, Sequel.qualify(table_name, order_by))
1414
dataset = dataset.order(order_type)
1515

16+
secondary_order_by = pagination_options.secondary_order_by
17+
dataset = dataset.order_append(Sequel.send(order_direction, Sequel.qualify(table_name, secondary_order_by))) if secondary_order_by
1618
dataset = dataset.order_append(Sequel.send(order_direction, Sequel.qualify(table_name, :guid))) if order_by != 'id' && has_guid_column
1719

1820
distinct_opt = dataset.opts[:distinct]

0 commit comments

Comments
 (0)