pact_broker 2.123.0 → 2.124.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/docs/CONFIGURATION.md +12 -0
- data/lib/pact_broker/config/runtime_configuration.rb +15 -0
- data/lib/pact_broker/domain/version.rb +9 -5
- data/lib/pact_broker/locale/en.yml +1 -0
- data/lib/pact_broker/matrix/parse_query.rb +3 -1
- data/lib/pact_broker/matrix/service.rb +5 -0
- data/lib/pact_broker/ui/controllers/can_i_deploy.rb +1 -1
- data/lib/pact_broker/ui/controllers/matrix.rb +2 -2
- data/lib/pact_broker/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3a0262f7dd8bce1f0c350ce3ec9b2b6920e8e36ec672bc34c327cd24adfaaf6a
|
|
4
|
+
data.tar.gz: b3a306b5074d7370d6693f4c5d4219a0c4a069a304035226eff502d6bd9ed3f6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6d363ce226b34c06e1cf6659d876c4699900598c6df64d9f5bc8c06a5a4b3d514431f4873307d71189fcfd5cd992f8caf582b26af92d2c5bc36cc61ad50a4a17
|
|
7
|
+
data.tar.gz: dcbce49bf421fb8f0294aba8bdf22be64d49e23f74a671531d9bf802717aefdbc58b154b4bfcc02a84e7fcd00709626e898a492f07c7cdd10e30b3d894398f38
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
## [2.124.0] _2026-11-11_
|
|
2
|
+
|
|
3
|
+
### 🚀 Features
|
|
4
|
+
|
|
5
|
+
- _(matrix)_ Add matrix_max_limit to cap the matrix query limit
|
|
6
|
+
|
|
7
|
+
### 🐛 Bug Fixes
|
|
8
|
+
|
|
9
|
+
- _(matrix)_ Support an environment in a selector alongside a version or latest
|
|
10
|
+
|
|
1
11
|
## [2.123.0] _2026-11-11_
|
|
2
12
|
|
|
3
13
|
### 🚀 Features
|
data/docs/CONFIGURATION.md
CHANGED
|
@@ -703,6 +703,18 @@ and at large numbers, the graph will not render due to browser performance issue
|
|
|
703
703
|
**Default:** `150`<br/>
|
|
704
704
|
**Allowed values:** A positive integer<br/>
|
|
705
705
|
|
|
706
|
+
### matrix_max_limit
|
|
707
|
+
|
|
708
|
+
The maximum value accepted for the `limit` parameter of a matrix query (`/matrix`).
|
|
709
|
+
A request with a larger `limit` is rejected with a 400 response. Very large limits can cause expensive database queries.
|
|
710
|
+
When not set, there is no maximum. A matrix query without a `limit` uses a limit of 100,
|
|
711
|
+
so the value must be 100 or greater, or the Pact Broker will not start.
|
|
712
|
+
|
|
713
|
+
**Environment variable name:** `PACT_BROKER_MATRIX_MAX_LIMIT`<br/>
|
|
714
|
+
**YAML configuration key name:** `matrix_max_limit`<br/>
|
|
715
|
+
**Default:** No maximum<br/>
|
|
716
|
+
**Allowed values:** An integer of 100 or greater<br/>
|
|
717
|
+
|
|
706
718
|
<br/>
|
|
707
719
|
|
|
708
720
|
## Miscellaneous
|
|
@@ -20,6 +20,7 @@ require "pact_broker/config/runtime_configuration_basic_auth_methods"
|
|
|
20
20
|
require "pact_broker/string_refinements"
|
|
21
21
|
require "pact_broker/hash_refinements"
|
|
22
22
|
require "pact_broker/error"
|
|
23
|
+
require "pact_broker/matrix/parse_query"
|
|
23
24
|
|
|
24
25
|
module PactBroker
|
|
25
26
|
module Config
|
|
@@ -97,9 +98,12 @@ module PactBroker
|
|
|
97
98
|
semver_formats: ["%M.%m.%p%s%d", "%M.%m", "%M"],
|
|
98
99
|
seed_example_data: true,
|
|
99
100
|
network_diagram_max_pacticipants: 150,
|
|
101
|
+
matrix_max_limit: nil,
|
|
100
102
|
features: {}
|
|
101
103
|
)
|
|
102
104
|
|
|
105
|
+
on_load :validate_matrix_max_limit!
|
|
106
|
+
|
|
103
107
|
def self.getter_and_setter_method_names
|
|
104
108
|
extra_methods = [
|
|
105
109
|
:warning_error_classes,
|
|
@@ -114,6 +118,7 @@ module PactBroker
|
|
|
114
118
|
coerce_types(
|
|
115
119
|
features: COERCE_FEATURES,
|
|
116
120
|
network_diagram_max_pacticipants: :integer,
|
|
121
|
+
matrix_max_limit: :integer,
|
|
117
122
|
webhook_certificates: COERCE_WEBHOOKS
|
|
118
123
|
)
|
|
119
124
|
sensitive_values(:database_url, :database_password)
|
|
@@ -226,6 +231,16 @@ module PactBroker
|
|
|
226
231
|
end
|
|
227
232
|
end
|
|
228
233
|
|
|
234
|
+
# A matrix query without a limit gets the default limit, so a lower matrix_max_limit
|
|
235
|
+
# would reject every request that does not set one.
|
|
236
|
+
# An empty or non-numeric value is coerced to 0, so it is rejected here too.
|
|
237
|
+
def validate_matrix_max_limit!
|
|
238
|
+
default_limit = PactBroker::Matrix::ParseQuery::DEFAULT_LIMIT
|
|
239
|
+
if matrix_max_limit && matrix_max_limit < default_limit
|
|
240
|
+
raise_validation_error("matrix_max_limit must be at least the default matrix limit (#{default_limit}), or not set")
|
|
241
|
+
end
|
|
242
|
+
end
|
|
243
|
+
|
|
229
244
|
def raise_validation_error(msg)
|
|
230
245
|
raise PactBroker::ConfigurationError, msg
|
|
231
246
|
end
|
|
@@ -85,20 +85,24 @@ module PactBroker
|
|
|
85
85
|
# end
|
|
86
86
|
end
|
|
87
87
|
|
|
88
|
+
# Filters on a UNION of version ids so the versions dataset stays unwrapped for later criteria.
|
|
89
|
+
# An OR of two IN subqueries is equivalent, but cannot use the versions primary key index.
|
|
88
90
|
def currently_in_environment(environment_name, pacticipant_name)
|
|
89
|
-
|
|
91
|
+
version_ids = version_ids_currently_deployed_to_environment(environment_name, pacticipant_name)
|
|
92
|
+
.union(version_ids_currently_supported_in_environment(environment_name, pacticipant_name), from_self: false)
|
|
93
|
+
where(Sequel[:versions][:id] => version_ids)
|
|
90
94
|
end
|
|
91
95
|
|
|
92
|
-
def
|
|
96
|
+
def version_ids_currently_deployed_to_environment(environment_name, pacticipant_name)
|
|
93
97
|
deployed_version_query = PactBroker::Deployments::DeployedVersion.currently_deployed.for_environment_name(environment_name)
|
|
94
98
|
deployed_version_query = deployed_version_query.for_pacticipant_name(pacticipant_name) if pacticipant_name
|
|
95
|
-
|
|
99
|
+
deployed_version_query.select(:version_id)
|
|
96
100
|
end
|
|
97
101
|
|
|
98
|
-
def
|
|
102
|
+
def version_ids_currently_supported_in_environment(environment_name, pacticipant_name)
|
|
99
103
|
supported_version_query = PactBroker::Deployments::ReleasedVersion.currently_supported.for_environment_name(environment_name)
|
|
100
104
|
supported_version_query = supported_version_query.for_pacticipant_name(pacticipant_name) if pacticipant_name
|
|
101
|
-
|
|
105
|
+
supported_version_query.select(:version_id)
|
|
102
106
|
end
|
|
103
107
|
|
|
104
108
|
def currently_deployed
|
|
@@ -97,6 +97,7 @@ en:
|
|
|
97
97
|
cannot_set_currently_deployed_true: The currentlyDeployed property cannot be set back to true. Please record a new deployment.
|
|
98
98
|
cannot_set_currently_supported_true: The currentlySupported property cannot be set back to true. Please record a new deployment.
|
|
99
99
|
invalid_limit: The limit must be 1 or greater.
|
|
100
|
+
matrix_limit_exceeds_maximum: "The limit must be %{max_limit} or less."
|
|
100
101
|
pacts_for_verification_selector_fallback_tag: "fallbackTag can only be set if latest is true"
|
|
101
102
|
pacts_for_verification_selector_matching_branch_requires_provider_version_branch: the providerVersionBranch must be specified when the selector matchingBranch=true is used
|
|
102
103
|
pacts_for_verification_selector_tag_and_branch_disallowed: "cannot specify both a tag and a branch"
|
|
@@ -4,6 +4,8 @@ require "pact_broker/matrix/unresolved_selector"
|
|
|
4
4
|
module PactBroker
|
|
5
5
|
module Matrix
|
|
6
6
|
class ParseQuery
|
|
7
|
+
DEFAULT_LIMIT = 100
|
|
8
|
+
|
|
7
9
|
# rubocop: disable Metrics/CyclomaticComplexity
|
|
8
10
|
# rubocop: disable Metrics/MethodLength
|
|
9
11
|
def self.call query
|
|
@@ -34,7 +36,7 @@ module PactBroker
|
|
|
34
36
|
if params.key?("limit") && params["limit"] != ""
|
|
35
37
|
options[:limit] = params["limit"]
|
|
36
38
|
else
|
|
37
|
-
options[:limit] =
|
|
39
|
+
options[:limit] = DEFAULT_LIMIT.to_s
|
|
38
40
|
end
|
|
39
41
|
|
|
40
42
|
if params.key?("latest") && params["latest"] != ""
|
|
@@ -140,6 +140,11 @@ module PactBroker
|
|
|
140
140
|
error_messages << message("errors.validation.invalid_limit")
|
|
141
141
|
end
|
|
142
142
|
|
|
143
|
+
max_limit = PactBroker.configuration.matrix_max_limit
|
|
144
|
+
if max_limit && options[:limit] && options[:limit].to_i > max_limit
|
|
145
|
+
error_messages << message("errors.validation.matrix_limit_exceeds_maximum", max_limit: max_limit)
|
|
146
|
+
end
|
|
147
|
+
|
|
143
148
|
error_messages
|
|
144
149
|
end
|
|
145
150
|
# rubocop: enable Metrics/CyclomaticComplexity
|
|
@@ -18,7 +18,7 @@ module PactBroker
|
|
|
18
18
|
get "/:pacticipant_name/latest-version/:tag/can-i-deploy/to/:environment_tag" do
|
|
19
19
|
# selector and options must be in sync with lib/pact_broker/api/resources/can_i_deploy_pacticipant_version_by_tag_to_tag_badge.rb
|
|
20
20
|
selectors = [ PactBroker::Matrix::UnresolvedSelector.new(pacticipant_name: params[:pacticipant_name], latest: true, tag: params[:tag]) ]
|
|
21
|
-
options = { latestby: "cvp", limit:
|
|
21
|
+
options = { latestby: "cvp", limit: PactBroker::Matrix::ParseQuery::DEFAULT_LIMIT, tag: params[:to] }
|
|
22
22
|
result = matrix_service.find(selectors, options)
|
|
23
23
|
lines = PactBroker::UI::ViewModels::MatrixLines.new(result, base_url: base_url)
|
|
24
24
|
locals = {
|
|
@@ -17,7 +17,7 @@ module PactBroker
|
|
|
17
17
|
|
|
18
18
|
get "/" do
|
|
19
19
|
selectors = [OpenStruct.new, OpenStruct.new]
|
|
20
|
-
options = { limit:
|
|
20
|
+
options = { limit: PactBroker::Matrix::ParseQuery::DEFAULT_LIMIT, latestby: nil }
|
|
21
21
|
locals = {
|
|
22
22
|
lines: [],
|
|
23
23
|
selectors: create_selector_objects(selectors),
|
|
@@ -50,7 +50,7 @@ module PactBroker
|
|
|
50
50
|
PactBroker::Matrix::UnresolvedSelector.new(pacticipant_name: params[:consumer_name]),
|
|
51
51
|
PactBroker::Matrix::UnresolvedSelector.new(pacticipant_name: params[:provider_name])
|
|
52
52
|
]
|
|
53
|
-
options = { latestby: "cvpv", limit:
|
|
53
|
+
options = { latestby: "cvpv", limit: PactBroker::Matrix::ParseQuery::DEFAULT_LIMIT }
|
|
54
54
|
lines = matrix_service.find(selectors, options)
|
|
55
55
|
lines = PactBroker::UI::ViewModels::MatrixLines.new(lines, base_url: base_url)
|
|
56
56
|
locals = {
|
data/lib/pact_broker/version.rb
CHANGED