pact_broker 2.50.1 → 2.51.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 +19 -0
- data/config/database.yml +4 -0
- data/lib/pact_broker/api/resources/base_resource.rb +1 -1
- data/lib/pact_broker/badges/service.rb +1 -0
- data/lib/pact_broker/db/clean.rb +14 -1
- data/lib/pact_broker/domain/version.rb +64 -2
- data/lib/pact_broker/matrix/every_row.rb +1 -1
- data/lib/pact_broker/matrix/parse_can_i_deploy_query.rb +4 -3
- data/lib/pact_broker/matrix/parse_query.rb +2 -1
- data/lib/pact_broker/matrix/quick_row.rb +12 -1
- data/lib/pact_broker/matrix/repository.rb +32 -27
- data/lib/pact_broker/matrix/resolved_selector.rb +4 -0
- data/lib/pact_broker/matrix/row.rb +2 -0
- data/lib/pact_broker/matrix/service.rb +6 -6
- data/lib/pact_broker/matrix/unresolved_selector.rb +53 -0
- data/lib/pact_broker/repositories/helpers.rb +4 -0
- data/lib/pact_broker/test/test_data_builder.rb +23 -3
- data/lib/pact_broker/ui/controllers/matrix.rb +2 -1
- data/lib/pact_broker/ui/view_models/matrix_line.rb +2 -2
- data/lib/pact_broker/version.rb +1 -1
- data/lib/pact_broker/versions/repository.rb +12 -14
- data/lib/pact_broker/webhooks/repository.rb +2 -0
- data/pact_broker.gemspec +2 -2
- data/script/docker/mysql-db-start.sh +0 -0
- data/script/prod/redact-data.sql +15 -7
- data/script/seed.rb +15 -1
- data/spec/features/create_webhook_spec.rb +11 -0
- data/spec/lib/pact_broker/api/decorators/dashboard_decorator_spec.rb +1 -10
- data/spec/lib/pact_broker/api/resources/base_resource_spec.rb +8 -0
- data/spec/lib/pact_broker/badges/service_spec.rb +36 -21
- data/spec/lib/pact_broker/db/clean_spec.rb +30 -98
- data/spec/lib/pact_broker/domain/version_spec.rb +139 -2
- data/spec/lib/pact_broker/integrations/integration_spec.rb +1 -2
- data/spec/lib/pact_broker/matrix/every_row_spec.rb +7 -0
- data/spec/lib/pact_broker/matrix/integration_spec.rb +19 -19
- data/spec/lib/pact_broker/matrix/quick_row_spec.rb +62 -20
- data/spec/lib/pact_broker/matrix/repository_dependency_spec.rb +2 -2
- data/spec/lib/pact_broker/matrix/repository_query_limit_spec.rb +35 -1
- data/spec/lib/pact_broker/matrix/repository_spec.rb +19 -27
- data/spec/lib/pact_broker/matrix/service_spec.rb +4 -3
- data/spec/lib/pact_broker/webhooks/repository_spec.rb +14 -6
- metadata +7 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 565c8989eb13e279daeb24f881fd53d0c56d72676d6a9eecaecbb3c52f823fa9
|
|
4
|
+
data.tar.gz: 54f7d26ec49742622aeffc7d66b9ee7903718ae507671b1384283bdd6317f16c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 61ca9dfdbebf5faf32ab678e9e4ca9d4bad0604a2fdd0c69653820adb001647f74ec980620d7943b330f245a03b4e138df2ebd19ac49dadc0888a0e9dd1393fc
|
|
7
|
+
data.tar.gz: 47c0ca191417d87ac73ac99e61e1de1a11942f512f00c734c07bbd773e4d5ff373d13b2b640845dcd702d62876a6b661deeaa713220ce41c5a303a0d2c19e6da
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
<a name="v2.51.0"></a>
|
|
2
|
+
### v2.51.0 (2020-03-11)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
#### Features
|
|
6
|
+
|
|
7
|
+
* **clean**
|
|
8
|
+
* all the latest version for all tags to be kept ([9ff7bbec](/../../commit/9ff7bbec))
|
|
9
|
+
* allow a maximum age to be specified for the versions to keep ([bc457492](/../../commit/bc457492))
|
|
10
|
+
* support specifying which versions to keep using selectors ([a06899eb](/../../commit/a06899eb))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
#### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* set consumer and provider relationships when a webhook is created and consumer/provider are set in the body of the request rather than the URL ([5ccdd31c](/../../commit/5ccdd31c))
|
|
16
|
+
* sort matrix rows by last action date ([f625c9ad](/../../commit/f625c9ad))
|
|
17
|
+
* gracefully handle badge redirects when the pact is not found ([2da36574](/../../commit/2da36574))
|
|
18
|
+
|
|
19
|
+
|
|
1
20
|
<a name="v2.50.1"></a>
|
|
2
21
|
### v2.50.1 (2020-02-27)
|
|
3
22
|
|
data/config/database.yml
CHANGED
|
@@ -39,6 +39,7 @@ module PactBroker
|
|
|
39
39
|
private
|
|
40
40
|
|
|
41
41
|
def badge_title pact, label, initials
|
|
42
|
+
return 'pact not found' if pact.nil?
|
|
42
43
|
title = case (label || '').downcase
|
|
43
44
|
when 'consumer' then prepare_name(pact.consumer_name, initials)
|
|
44
45
|
when 'provider' then prepare_name(pact.provider_name, initials)
|
data/lib/pact_broker/db/clean.rb
CHANGED
|
@@ -17,12 +17,25 @@ module PactBroker
|
|
|
17
17
|
deleted_counts = {}
|
|
18
18
|
kept_counts = {}
|
|
19
19
|
date = options[:date]
|
|
20
|
+
|
|
21
|
+
version_ids_to_keep = nil
|
|
22
|
+
|
|
23
|
+
if options[:keep]
|
|
24
|
+
version_ids_to_keep = options[:keep].collect do | selector |
|
|
25
|
+
PactBroker::Domain::Version.select(:id).for_selector(selector)
|
|
26
|
+
end.reduce(&:union)
|
|
27
|
+
end
|
|
28
|
+
|
|
20
29
|
pact_publication_ids_to_delete = if date
|
|
21
30
|
db[:pact_publications].select(:id).where(Sequel.lit('created_at < ?', date))
|
|
31
|
+
elsif version_ids_to_keep
|
|
32
|
+
db[:pact_publications].select(:id).where(consumer_version_id: version_ids_to_keep).invert
|
|
22
33
|
else
|
|
23
|
-
db[:
|
|
34
|
+
keep = db[:latest_tagged_pact_publications].select(:id).union(db[:latest_pact_publications].select(:id))
|
|
35
|
+
db[:pact_publications].select(:id).where(id: keep).invert
|
|
24
36
|
end
|
|
25
37
|
|
|
38
|
+
|
|
26
39
|
deleted_counts[:pact_publications] = pact_publication_ids_to_delete.count
|
|
27
40
|
kept_counts[:pact_publications] = db[:pact_publications].where(id: pact_publication_ids_to_delete).invert.count
|
|
28
41
|
|
|
@@ -6,6 +6,8 @@ require 'pact_broker/tags/tag_with_latest_flag'
|
|
|
6
6
|
module PactBroker
|
|
7
7
|
module Domain
|
|
8
8
|
class Version < Sequel::Model
|
|
9
|
+
plugin :timestamps, update_on_create: true
|
|
10
|
+
|
|
9
11
|
set_primary_key :id
|
|
10
12
|
one_to_many :pact_publications, order: :revision_number, class: "PactBroker::Pacts::PactPublication", key: :consumer_version_id
|
|
11
13
|
associate(:many_to_one, :pacticipant, :class => "PactBroker::Domain::Pacticipant", :key => :pacticipant_id, :primary_key => :id)
|
|
@@ -15,10 +17,72 @@ module PactBroker
|
|
|
15
17
|
dataset_module do
|
|
16
18
|
include PactBroker::Repositories::Helpers
|
|
17
19
|
|
|
20
|
+
def where_pacticipant_name(pacticipant_name)
|
|
21
|
+
join(:pacticipants) do | p |
|
|
22
|
+
Sequel.&(
|
|
23
|
+
{ Sequel[first_source_alias][:pacticipant_id] => Sequel[p][:id] },
|
|
24
|
+
name_like(Sequel[p][:name], pacticipant_name)
|
|
25
|
+
)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def where_tag(tag)
|
|
30
|
+
if tag == true
|
|
31
|
+
join(:tags, Sequel[:tags][:version_id] => Sequel[first_source_alias][:id])
|
|
32
|
+
else
|
|
33
|
+
join(:tags) do | tags |
|
|
34
|
+
Sequel.&(
|
|
35
|
+
{ Sequel[first_source_alias][:id] => Sequel[tags][:version_id] },
|
|
36
|
+
name_like(Sequel[tags][:name], tag)
|
|
37
|
+
)
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def where_number(number)
|
|
43
|
+
where(name_like(:number, number))
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def where_age_less_than(days)
|
|
47
|
+
start_date = Date.today - days
|
|
48
|
+
where{ versions[:created_at] >= start_date }
|
|
49
|
+
end
|
|
50
|
+
|
|
18
51
|
def delete
|
|
19
52
|
PactBroker::Domain::Tag.where(version: self).delete
|
|
20
53
|
super
|
|
21
54
|
end
|
|
55
|
+
|
|
56
|
+
def for_selector(selector)
|
|
57
|
+
query = self
|
|
58
|
+
query = query.where_pacticipant_name(selector.pacticipant_name) if selector.pacticipant_name
|
|
59
|
+
query = query.where_tag(selector.tag) if selector.tag
|
|
60
|
+
query = query.where_number(selector.pacticipant_version_number) if selector.pacticipant_version_number
|
|
61
|
+
query = query.where_age_less_than(selector.max_age) if selector.max_age
|
|
62
|
+
|
|
63
|
+
if selector.latest
|
|
64
|
+
calculate_max_version_order_and_join_back_to_versions(query, selector)
|
|
65
|
+
else
|
|
66
|
+
query
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# private
|
|
71
|
+
|
|
72
|
+
def calculate_max_version_order_and_join_back_to_versions(query, selector)
|
|
73
|
+
versions_join = {
|
|
74
|
+
Sequel[:versions][:pacticipant_id] => Sequel[:latest][:pacticipant_id],
|
|
75
|
+
Sequel[:versions][:order] => Sequel[:latest][:latest_version_order]
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
group_by_cols = selector.tag == true ? [:pacticipant_id, Sequel[:tags][:name]] : [:pacticipant_id]
|
|
79
|
+
|
|
80
|
+
max_order_for_each_pacticipant = query
|
|
81
|
+
.select_group(*group_by_cols)
|
|
82
|
+
.select_append{ max(order).as(latest_version_order) }
|
|
83
|
+
|
|
84
|
+
join(max_order_for_each_pacticipant, versions_join, table_alias: :latest)
|
|
85
|
+
end
|
|
22
86
|
end
|
|
23
87
|
|
|
24
88
|
def after_create
|
|
@@ -43,8 +107,6 @@ module PactBroker
|
|
|
43
107
|
pact_publications.last
|
|
44
108
|
end
|
|
45
109
|
end
|
|
46
|
-
|
|
47
|
-
Version.plugin :timestamps, :update_on_create=>true
|
|
48
110
|
end
|
|
49
111
|
end
|
|
50
112
|
|
|
@@ -16,7 +16,7 @@ module PactBroker
|
|
|
16
16
|
Sequel[:v][:id].as(:verification_id)
|
|
17
17
|
]
|
|
18
18
|
|
|
19
|
-
ALL_COLUMNS = CONSUMER_COLUMNS + CONSUMER_VERSION_COLUMNS + PACT_COLUMNS +
|
|
19
|
+
ALL_COLUMNS = [LAST_ACTION_DATE] + CONSUMER_COLUMNS + CONSUMER_VERSION_COLUMNS + PACT_COLUMNS +
|
|
20
20
|
PROVIDER_COLUMNS + PROVIDER_VERSION_COLUMNS + VERIFICATION_COLUMNS
|
|
21
21
|
|
|
22
22
|
SELECT_ALL_COLUMN_ARGS = [:select_all_columns] + ALL_COLUMNS
|
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
require 'rack/utils'
|
|
2
|
+
require 'pact_broker/matrix/unresolved_selector'
|
|
2
3
|
|
|
3
4
|
module PactBroker
|
|
4
5
|
module Matrix
|
|
5
6
|
class ParseCanIDeployQuery
|
|
6
7
|
def self.call params
|
|
7
|
-
selector =
|
|
8
|
+
selector = PactBroker::Matrix::UnresolvedSelector.new
|
|
8
9
|
options = {
|
|
9
10
|
latestby: 'cvp',
|
|
10
11
|
latest: true
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
if params[:pacticipant].is_a?(String)
|
|
14
|
-
selector
|
|
15
|
+
selector.pacticipant_name = params[:pacticipant]
|
|
15
16
|
end
|
|
16
17
|
|
|
17
18
|
if params[:version].is_a?(String)
|
|
18
|
-
selector
|
|
19
|
+
selector.pacticipant_version_number = params[:version]
|
|
19
20
|
end
|
|
20
21
|
|
|
21
22
|
if params[:to].is_a?(String)
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
require 'rack/utils'
|
|
2
|
+
require 'pact_broker/matrix/unresolved_selector'
|
|
2
3
|
|
|
3
4
|
module PactBroker
|
|
4
5
|
module Matrix
|
|
@@ -6,7 +7,7 @@ module PactBroker
|
|
|
6
7
|
def self.call query
|
|
7
8
|
params = Rack::Utils.parse_nested_query(query)
|
|
8
9
|
selectors = (params['q'] || []).collect do |i|
|
|
9
|
-
p =
|
|
10
|
+
p = PactBroker::Matrix::UnresolvedSelector.new
|
|
10
11
|
p[:pacticipant_name] = i['pacticipant'] if i['pacticipant'] && i['pacticipant'] != ''
|
|
11
12
|
p[:pacticipant_version_number] = i['version'] if i['version'] && i['version'] != ''
|
|
12
13
|
p[:latest] = true if i['latest'] == 'true'
|
|
@@ -59,10 +59,13 @@ module PactBroker
|
|
|
59
59
|
VERIFICATION_COLUMNS = [
|
|
60
60
|
Sequel[:v][:verification_id]
|
|
61
61
|
]
|
|
62
|
-
|
|
62
|
+
LAST_ACTION_DATE = Sequel.lit("CASE WHEN (pv.created_at IS NOT NULL AND pv.created_at > cv.created_at) THEN pv.created_at ELSE cv.created_at END").as(:last_action_date)
|
|
63
|
+
|
|
64
|
+
ALL_COLUMNS = [LAST_ACTION_DATE] + CONSUMER_COLUMNS + CONSUMER_VERSION_COLUMNS + PACT_COLUMNS +
|
|
63
65
|
PROVIDER_COLUMNS + PROVIDER_VERSION_COLUMNS + VERIFICATION_COLUMNS
|
|
64
66
|
|
|
65
67
|
|
|
68
|
+
|
|
66
69
|
# cachable select arguments
|
|
67
70
|
SELECT_ALL_COLUMN_ARGS = [:select_all_columns] + ALL_COLUMNS
|
|
68
71
|
SELECT_PACTICIPANT_IDS_ARGS = [:select_pacticipant_ids, Sequel[:p][:consumer_id], Sequel[:p][:provider_id]]
|
|
@@ -127,6 +130,10 @@ module PactBroker
|
|
|
127
130
|
Sequel.desc(:verification_id))
|
|
128
131
|
end
|
|
129
132
|
|
|
133
|
+
def order_by_last_action_date
|
|
134
|
+
order(Sequel.desc(1), Sequel.desc(:consumer_version_order))
|
|
135
|
+
end
|
|
136
|
+
|
|
130
137
|
def eager_all_the_things
|
|
131
138
|
eager(:consumer)
|
|
132
139
|
.eager(:provider)
|
|
@@ -376,6 +383,10 @@ module PactBroker
|
|
|
376
383
|
return_or_raise_if_not_set(:provider_version_order)
|
|
377
384
|
end
|
|
378
385
|
|
|
386
|
+
def last_action_date
|
|
387
|
+
return_or_raise_if_not_set(:last_action_date)
|
|
388
|
+
end
|
|
389
|
+
|
|
379
390
|
def has_verification?
|
|
380
391
|
!!verification_id
|
|
381
392
|
end
|
|
@@ -8,6 +8,7 @@ require 'pact_broker/matrix/query_results'
|
|
|
8
8
|
require 'pact_broker/matrix/integration'
|
|
9
9
|
require 'pact_broker/matrix/query_results_with_deployment_status_summary'
|
|
10
10
|
require 'pact_broker/matrix/resolved_selector'
|
|
11
|
+
require 'pact_broker/matrix/unresolved_selector'
|
|
11
12
|
require 'pact_broker/verifications/latest_verification_id_for_pact_version_and_provider_version'
|
|
12
13
|
require 'pact_broker/pacts/latest_pact_publications_by_consumer_version'
|
|
13
14
|
|
|
@@ -75,7 +76,7 @@ module PactBroker
|
|
|
75
76
|
end
|
|
76
77
|
|
|
77
78
|
def find_for_consumer_and_provider pacticipant_1_name, pacticipant_2_name
|
|
78
|
-
selectors = [
|
|
79
|
+
selectors = [ UnresolvedSelector.new(pacticipant_name: pacticipant_1_name), UnresolvedSelector.new(pacticipant_name: pacticipant_2_name)]
|
|
79
80
|
options = { latestby: 'cvpv' }
|
|
80
81
|
find(selectors, options)
|
|
81
82
|
end
|
|
@@ -118,7 +119,7 @@ module PactBroker
|
|
|
118
119
|
# that don't have verifications, so we need to include them all.
|
|
119
120
|
lines.group_by{|line| group_by_columns.collect{|key| line.send(key) }}
|
|
120
121
|
.values
|
|
121
|
-
.collect{ | lines | lines.first.provider_version_number.nil? ? lines : lines.
|
|
122
|
+
.collect{ | lines | lines.first.provider_version_number.nil? ? lines : lines.sort_by(&:provider_version_order).last }
|
|
122
123
|
.flatten
|
|
123
124
|
end
|
|
124
125
|
|
|
@@ -126,7 +127,17 @@ module PactBroker
|
|
|
126
127
|
query = base_model(options)
|
|
127
128
|
.select_all_columns
|
|
128
129
|
.matching_selectors(selectors)
|
|
129
|
-
|
|
130
|
+
|
|
131
|
+
# These two could both probably use the order by last action date,
|
|
132
|
+
# but I just want to give the implications a little more thought before changing
|
|
133
|
+
# the can-i-deploy query order.
|
|
134
|
+
if selectors.all?(&:only_pacticipant_name_specified?)
|
|
135
|
+
# Can only be the UI, as can-i-deploy requires a version to be specified
|
|
136
|
+
query = query.order_by_last_action_date
|
|
137
|
+
else
|
|
138
|
+
query = query.order_by_names_ascending_most_recent_first
|
|
139
|
+
end
|
|
140
|
+
|
|
130
141
|
query = query.limit(options[:limit]) if options[:limit]
|
|
131
142
|
query.eager_all_the_things.all
|
|
132
143
|
end
|
|
@@ -138,12 +149,26 @@ module PactBroker
|
|
|
138
149
|
# Find the version number for selectors with the latest and/or tag specified
|
|
139
150
|
def resolve_versions_and_add_ids(selectors, selector_type)
|
|
140
151
|
selectors.collect do | selector |
|
|
141
|
-
pacticipant = PactBroker::Domain::Pacticipant.find(name: selector
|
|
152
|
+
pacticipant = PactBroker::Domain::Pacticipant.find(name: selector.pacticipant_name)
|
|
142
153
|
versions = find_versions_for_selector(selector)
|
|
143
154
|
build_resolved_selectors(pacticipant, versions, selector, selector_type)
|
|
144
155
|
end.flatten
|
|
145
156
|
end
|
|
146
157
|
|
|
158
|
+
def find_versions_for_selector(selector)
|
|
159
|
+
# For selectors that just set the pacticipant name, there's no need to resolve the version -
|
|
160
|
+
# only the pacticipant ID will be used in the query
|
|
161
|
+
return nil unless (selector.tag || selector.latest || selector.pacticipant_version_number)
|
|
162
|
+
|
|
163
|
+
versions = version_repository.find_versions_for_selector(selector)
|
|
164
|
+
|
|
165
|
+
if selector.latest
|
|
166
|
+
[versions.first]
|
|
167
|
+
else
|
|
168
|
+
versions.empty? ? [nil] : versions
|
|
169
|
+
end
|
|
170
|
+
end
|
|
171
|
+
|
|
147
172
|
# When a single selector specifies multiple versions (eg. "all prod pacts"), this expands
|
|
148
173
|
# the single selector into one selector for each version.
|
|
149
174
|
def build_resolved_selectors(pacticipant, versions, original_selector, selector_type)
|
|
@@ -160,24 +185,6 @@ module PactBroker
|
|
|
160
185
|
end
|
|
161
186
|
end
|
|
162
187
|
|
|
163
|
-
def find_versions_for_selector(selector)
|
|
164
|
-
if selector[:tag] && selector[:latest]
|
|
165
|
-
version = version_repository.find_by_pacticipant_name_and_latest_tag(selector[:pacticipant_name], selector[:tag])
|
|
166
|
-
[version]
|
|
167
|
-
elsif selector[:latest]
|
|
168
|
-
version = version_repository.find_latest_by_pacticpant_name(selector[:pacticipant_name])
|
|
169
|
-
[version]
|
|
170
|
-
elsif selector[:tag]
|
|
171
|
-
versions = version_repository.find_by_pacticipant_name_and_tag(selector[:pacticipant_name], selector[:tag])
|
|
172
|
-
versions.any? ? versions : [nil]
|
|
173
|
-
elsif selector[:pacticipant_version_number]
|
|
174
|
-
version = version_repository.find_by_pacticipant_name_and_number(selector[:pacticipant_name], selector[:pacticipant_version_number])
|
|
175
|
-
[version]
|
|
176
|
-
else
|
|
177
|
-
nil
|
|
178
|
-
end
|
|
179
|
-
end
|
|
180
|
-
|
|
181
188
|
def infer_selectors_for_integrations?(options)
|
|
182
189
|
options[:latest] || options[:tag]
|
|
183
190
|
end
|
|
@@ -193,11 +200,9 @@ module PactBroker
|
|
|
193
200
|
|
|
194
201
|
def build_inferred_selectors(inferred_pacticipant_names, options)
|
|
195
202
|
selectors = inferred_pacticipant_names.collect do | pacticipant_name |
|
|
196
|
-
selector =
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
selector[:tag] = options[:tag] if options[:tag]
|
|
200
|
-
selector[:latest] = options[:latest] if options[:latest]
|
|
203
|
+
selector = UnresolvedSelector.new(pacticipant_name: pacticipant_name)
|
|
204
|
+
selector.tag = options[:tag] if options[:tag]
|
|
205
|
+
selector.latest = options[:latest] if options[:latest]
|
|
201
206
|
selector
|
|
202
207
|
end
|
|
203
208
|
resolve_versions_and_add_ids(selectors, :inferred)
|
|
@@ -5,6 +5,8 @@ require 'pact_broker/logging'
|
|
|
5
5
|
require 'pact_broker/verifications/latest_verification_for_consumer_version_tag'
|
|
6
6
|
require 'pact_broker/verifications/latest_verification_for_consumer_and_provider'
|
|
7
7
|
|
|
8
|
+
# TODO DELETE THIS!!!
|
|
9
|
+
|
|
8
10
|
module PactBroker
|
|
9
11
|
module Matrix
|
|
10
12
|
class Row < Sequel::Model(:matrix)
|
|
@@ -17,22 +17,22 @@ module PactBroker
|
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
def find_for_consumer_and_provider params, options = {}
|
|
20
|
-
selectors = [
|
|
20
|
+
selectors = [ UnresolvedSelector.new(pacticipant_name: params[:consumer_name]), UnresolvedSelector.new(pacticipant_name: params[:provider_name]) ]
|
|
21
21
|
find(selectors, options)
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
def find_for_consumer_and_provider_with_tags params
|
|
25
|
-
|
|
25
|
+
consumer_selector = UnresolvedSelector.new(
|
|
26
26
|
pacticipant_name: params[:consumer_name],
|
|
27
27
|
tag: params[:tag],
|
|
28
28
|
latest: true
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
)
|
|
30
|
+
provider_selector = UnresolvedSelector.new(
|
|
31
31
|
pacticipant_name: params[:provider_name],
|
|
32
32
|
tag: params[:provider_tag],
|
|
33
33
|
latest: true
|
|
34
|
-
|
|
35
|
-
selectors = [
|
|
34
|
+
)
|
|
35
|
+
selectors = [consumer_selector, provider_selector]
|
|
36
36
|
options = { latestby: 'cvpv' }
|
|
37
37
|
if validate_selectors(selectors).empty?
|
|
38
38
|
matrix_repository.find(selectors, options).first
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
module PactBroker
|
|
2
|
+
module Matrix
|
|
3
|
+
class UnresolvedSelector < Hash
|
|
4
|
+
def initialize(params = {})
|
|
5
|
+
merge!(params)
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def pacticipant_name
|
|
9
|
+
self[:pacticipant_name]
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def pacticipant_version_number
|
|
13
|
+
self[:pacticipant_version_number]
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def latest?
|
|
17
|
+
!!latest
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def latest
|
|
21
|
+
self[:latest]
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def tag
|
|
25
|
+
self[:tag]
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def latest= latest
|
|
29
|
+
self[:latest] = latest
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def tag= tag
|
|
33
|
+
self[:tag] = tag
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def pacticipant_name= pacticipant_name
|
|
37
|
+
self[:pacticipant_name] = pacticipant_name
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def pacticipant_version_number= pacticipant_version_number
|
|
41
|
+
self[:pacticipant_version_number] = pacticipant_version_number
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def max_age= max_age
|
|
45
|
+
self[:max_age] = max_age
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def max_age
|
|
49
|
+
self[:max_age]
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|