pact_broker 2.9.0 → 2.10.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 +24 -1
- data/config.ru +2 -2
- data/lib/pact_broker/api/decorators/relationships_csv_decorator.rb +6 -6
- data/lib/pact_broker/domain/group.rb +3 -3
- data/lib/pact_broker/domain/{relationship.rb → index_item.rb} +27 -7
- data/lib/pact_broker/groups/service.rb +2 -3
- data/lib/pact_broker/index/service.rb +56 -0
- data/lib/pact_broker/pacticipants/service.rb +0 -12
- data/lib/pact_broker/pacts/pact_publication.rb +4 -0
- data/lib/pact_broker/pacts/repository.rb +1 -1
- data/lib/pact_broker/relationships/groupify.rb +8 -8
- data/lib/pact_broker/services.rb +5 -0
- data/lib/pact_broker/tags/repository.rb +11 -1
- data/lib/pact_broker/tags/service.rb +3 -1
- data/lib/pact_broker/ui/app.rb +3 -3
- data/lib/pact_broker/ui/controllers/clusters.rb +1 -1
- data/lib/pact_broker/ui/controllers/groups.rb +1 -1
- data/lib/pact_broker/ui/controllers/index.rb +22 -0
- data/lib/pact_broker/ui/view_models/{relationship.rb → index_item.rb} +32 -5
- data/lib/pact_broker/ui/view_models/index_items.rb +30 -0
- data/lib/pact_broker/ui/views/index/show-with-tags.haml +83 -0
- data/lib/pact_broker/ui/views/{relationships → index}/show.haml +18 -18
- data/lib/pact_broker/ui/views/matrix/show.haml +1 -1
- data/lib/pact_broker/verifications/repository.rb +3 -0
- data/lib/pact_broker/version.rb +1 -1
- data/public/stylesheets/{relationships.css → index.css} +0 -0
- data/script/seed.rb +55 -39
- data/spec/integration/app_spec.rb +1 -1
- data/spec/integration/endpoints/{group.rb → group_spec.rb} +0 -3
- data/spec/integration/ui/index_spec.rb +36 -0
- data/spec/lib/pact_broker/domain/group_spec.rb +3 -3
- data/spec/lib/pact_broker/domain/{relationship_spec.rb → index_items_spec.rb} +3 -3
- data/spec/lib/pact_broker/groups/service_spec.rb +5 -4
- data/spec/lib/pact_broker/index/service_spec.rb +131 -0
- data/spec/lib/pact_broker/pacticipants/service_spec.rb +2 -35
- data/spec/lib/pact_broker/pacts/pact_publication_spec.rb +35 -0
- data/spec/lib/pact_broker/pacts/repository_spec.rb +16 -14
- data/spec/lib/pact_broker/relationships/groupify_spec.rb +7 -7
- data/spec/lib/pact_broker/tags/repository_spec.rb +23 -1
- data/spec/lib/pact_broker/tags/service_spec.rb +0 -1
- data/spec/lib/pact_broker/ui/controllers/index_spec.rb +71 -0
- data/spec/lib/pact_broker/ui/view_models/{relationship_spec.rb → index_item_spec.rb} +38 -18
- data/spec/lib/pact_broker/ui/view_models/{relationships_spec.rb → index_items_spec.rb} +10 -10
- metadata +26 -18
- data/lib/pact_broker/ui/controllers/relationships.rb +0 -21
- data/lib/pact_broker/ui/view_models/relationships.rb +0 -30
- data/spec/lib/pact_broker/ui/controllers/relationships_spec.rb +0 -39
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c0922b07d5bcc9db298ee95d05ce341ba4ff3030
|
4
|
+
data.tar.gz: a94f37ca9589e003343ad2bd2b7f745740ca4620
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a93bced15dab3e293a8198ae278c666b8c15457bd4c30a552d1bc8c3cb4328e8eca20c4808132626cfa050b4a43fbb65e774a660f16c6a764fd6e511aa9d44f
|
7
|
+
data.tar.gz: '0239cfe02ffb216cb6cc7551a7e11dfba098f1e2a520b3f7ef13b321bbc8d49aa433a3986d97c569f9d98c084ddc2a46f8d48013072bf107ee095c5c1ae4af2e'
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,18 @@
|
|
1
|
+
<a name="v2.10.0"></a>
|
2
|
+
### v2.10.0 (2017-11-11)
|
3
|
+
|
4
|
+
|
5
|
+
#### Features
|
6
|
+
|
7
|
+
* **prod pacts in index**
|
8
|
+
* allow all tags to be shown on index ([0a1f0ee](/../../commit/0a1f0ee))
|
9
|
+
* allow tags shown in index to be configured via query string ([4eca8ee](/../../commit/4eca8ee))
|
10
|
+
* show pacts tagged as the 'prod' or 'production' versions on the index page ([b58b7a3](/../../commit/b58b7a3))
|
11
|
+
|
12
|
+
* **index page**
|
13
|
+
* truncate git shas in table ([94da4c7](/../../commit/94da4c7))
|
14
|
+
|
15
|
+
|
1
16
|
<a name="v2.9.0"></a>
|
2
17
|
### v2.9.0 (2017-11-09)
|
3
18
|
|
@@ -6,7 +21,7 @@
|
|
6
21
|
* **webhook templating**
|
7
22
|
* add support for ${pactbroker.pactUrl} in query and body ([0eed596](/../../commit/0eed596))
|
8
23
|
|
9
|
-
* **matrix**
|
24
|
+
* **matrix** _(note that the matrix resource is still in beta, and there may be breaking changes in the future)_
|
10
25
|
* allow query to determine if a particular pacticipant version is compatible with the latest tagged versions of all its dependencies ([ba4a1cc](/../../commit/ba4a1cc))
|
11
26
|
|
12
27
|
<a name="v2.8.0.beta.5"></a>
|
@@ -86,6 +101,14 @@
|
|
86
101
|
|
87
102
|
* show webhook status as not_run when all triggered webhooks are not_run ([2d014b2](/../../commit/2d014b2))
|
88
103
|
|
104
|
+
<a name="v2.7.0.beta.1"></a>
|
105
|
+
### v2.7.0.beta.1 (2017-10-16)
|
106
|
+
|
107
|
+
#### Features
|
108
|
+
|
109
|
+
* **prod pacts in index**
|
110
|
+
* show pacts tagged as the 'prod' or 'production' versions on the index page ([b58b7a3](/../../commit/b58b7a3))
|
111
|
+
|
89
112
|
<a name="v2.6.0"></a>
|
90
113
|
### v2.6.0 (2017-10-06)
|
91
114
|
|
data/config.ru
CHANGED
@@ -2,14 +2,14 @@ require File.dirname(__FILE__) + '/config/boot'
|
|
2
2
|
require 'db'
|
3
3
|
require 'pact_broker/api'
|
4
4
|
require 'rack/hal_browser'
|
5
|
-
require 'pact_broker/ui/controllers/
|
5
|
+
require 'pact_broker/ui/controllers/index'
|
6
6
|
|
7
7
|
|
8
8
|
use Rack::Static, :urls => ["/stylesheets", "/css", "/fonts", "/js", "/javascripts", "/images"], :root => "public"
|
9
9
|
use Rack::HalBrowser::Redirect, :exclude => ['/diagnostic', '/trace','/index']
|
10
10
|
|
11
11
|
run Rack::URLMap.new(
|
12
|
-
'/ui/relationships' => PactBroker::UI::Controllers::
|
12
|
+
'/ui/relationships' => PactBroker::UI::Controllers::Index,
|
13
13
|
'/network-graph' => Rack::File.new("#{File.dirname(__FILE__)}/public/Network Graph REA.html"),
|
14
14
|
'/' => PactBroker::API,
|
15
15
|
)
|
@@ -11,17 +11,17 @@ module PactBroker
|
|
11
11
|
|
12
12
|
def initialize pacts
|
13
13
|
@pacts = pacts
|
14
|
-
@
|
14
|
+
@index_items = pacts.collect{|pact| PactBroker::Domain::IndexItem.new(pact.consumer,pact.provider)}
|
15
15
|
end
|
16
16
|
|
17
17
|
def to_csv
|
18
18
|
hash = {}
|
19
|
-
pacticipants = @
|
19
|
+
pacticipants = @index_items.collect{|r| r.pacticipants}.flatten.uniq
|
20
20
|
|
21
|
-
@
|
22
|
-
hash[
|
23
|
-
hash[
|
24
|
-
hash[
|
21
|
+
@index_items.each do | index_item |
|
22
|
+
hash[index_item.consumer.id] ||= pacticipant_array(index_item.consumer, hash.size + 1)
|
23
|
+
hash[index_item.provider.id] ||= pacticipant_array(index_item.provider, hash.size + 1)
|
24
|
+
hash[index_item.consumer.id] << index_item.provider.id
|
25
25
|
end
|
26
26
|
|
27
27
|
max_length = hash.values.collect{|array| array.size}.max
|
@@ -2,8 +2,8 @@ module PactBroker
|
|
2
2
|
module Domain
|
3
3
|
class Group < Array
|
4
4
|
|
5
|
-
def initialize *
|
6
|
-
self.concat
|
5
|
+
def initialize *index_items
|
6
|
+
self.concat index_items.flatten
|
7
7
|
end
|
8
8
|
|
9
9
|
def == other
|
@@ -11,7 +11,7 @@ module PactBroker
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def include_pacticipant? pacticipant
|
14
|
-
any? { |
|
14
|
+
any? { | index_item | index_item.include? pacticipant }
|
15
15
|
end
|
16
16
|
|
17
17
|
end
|
@@ -3,26 +3,30 @@ require 'pact_broker/webhooks/status'
|
|
3
3
|
|
4
4
|
module PactBroker
|
5
5
|
module Domain
|
6
|
-
class
|
6
|
+
class IndexItem
|
7
7
|
|
8
8
|
attr_reader :consumer, :provider, :latest_pact, :latest_verification, :webhooks
|
9
9
|
|
10
|
-
def initialize consumer, provider, latest_pact = nil, latest_verification = nil, webhooks = [], triggered_webhooks = []
|
10
|
+
def initialize consumer, provider, latest_pact = nil, latest = true, latest_verification = nil, webhooks = [], triggered_webhooks = [], tags = []
|
11
11
|
@consumer = consumer
|
12
12
|
@provider = provider
|
13
13
|
@latest_pact = latest_pact
|
14
|
+
@latest = latest
|
14
15
|
@latest_verification = latest_verification
|
15
16
|
@webhooks = webhooks
|
16
17
|
@triggered_webhooks = triggered_webhooks
|
18
|
+
@tags = tags
|
17
19
|
end
|
18
20
|
|
19
|
-
def self.create consumer, provider, latest_pact, latest_verification, webhooks = [], triggered_webhooks = []
|
20
|
-
new consumer, provider, latest_pact, latest_verification, webhooks, triggered_webhooks
|
21
|
+
def self.create consumer, provider, latest_pact, latest, latest_verification, webhooks = [], triggered_webhooks = [], tags = []
|
22
|
+
new consumer, provider, latest_pact, latest, latest_verification, webhooks, triggered_webhooks, tags
|
21
23
|
end
|
22
24
|
|
23
25
|
def eq? other
|
24
|
-
|
25
|
-
other.latest_pact == latest_pact &&
|
26
|
+
IndexItem === other && other.consumer == consumer && other.provider == provider &&
|
27
|
+
other.latest_pact == latest_pact &&
|
28
|
+
other.latest? == latest? &&
|
29
|
+
other.latest_verification == latest_verification &&
|
26
30
|
other.webhooks == webhooks
|
27
31
|
end
|
28
32
|
|
@@ -42,6 +46,22 @@ module PactBroker
|
|
42
46
|
@latest_pact
|
43
47
|
end
|
44
48
|
|
49
|
+
def latest?
|
50
|
+
@latest
|
51
|
+
end
|
52
|
+
|
53
|
+
def consumer_version_number
|
54
|
+
@latest_pact.consumer_version_number
|
55
|
+
end
|
56
|
+
|
57
|
+
def provider_version_number
|
58
|
+
@latest_verification ? @latest_verification.provider_version_number : nil
|
59
|
+
end
|
60
|
+
|
61
|
+
def tag_names
|
62
|
+
@tags
|
63
|
+
end
|
64
|
+
|
45
65
|
def any_webhooks?
|
46
66
|
@webhooks.any?
|
47
67
|
end
|
@@ -97,7 +117,7 @@ module PactBroker
|
|
97
117
|
end
|
98
118
|
|
99
119
|
def to_s
|
100
|
-
"
|
120
|
+
"Pact between #{consumer_name} and #{provider_name}"
|
101
121
|
end
|
102
122
|
|
103
123
|
def to_a
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'pact_broker/repositories'
|
2
|
+
require 'pact_broker/logging'
|
3
|
+
require 'pact_broker/domain/index_item'
|
4
|
+
|
5
|
+
module PactBroker
|
6
|
+
|
7
|
+
module Index
|
8
|
+
class Service
|
9
|
+
|
10
|
+
extend PactBroker::Repositories
|
11
|
+
extend PactBroker::Services
|
12
|
+
extend PactBroker::Logging
|
13
|
+
|
14
|
+
def self.find_index_items options = {}
|
15
|
+
pact_repository
|
16
|
+
.find_latest_pacts
|
17
|
+
.collect { | pact| build_index_item_rows(pact, tags_for(pact, options)) }
|
18
|
+
.flatten
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.tags_for(pact, options)
|
22
|
+
if options[:tags] == true
|
23
|
+
tag_service.find_all_tag_names_for_pacticipant(pact.consumer_name)
|
24
|
+
elsif options[:tags].is_a?(Array)
|
25
|
+
options[:tags]
|
26
|
+
else
|
27
|
+
[]
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.build_index_item_rows(pact, tags)
|
32
|
+
index_items = [build_latest_pact_index_item(pact, tags)]
|
33
|
+
tags.each do | tag |
|
34
|
+
index_items << build_index_item_for_tagged_pact(pact, tag)
|
35
|
+
end
|
36
|
+
index_items.compact
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.build_latest_pact_index_item pact, tags
|
40
|
+
latest_verification = verification_service.find_latest_verification_for(pact.consumer, pact.provider)
|
41
|
+
webhooks = webhook_service.find_by_consumer_and_provider pact.consumer, pact.provider
|
42
|
+
triggered_webhooks = webhook_service.find_latest_triggered_webhooks pact.consumer, pact.provider
|
43
|
+
tag_names = pact.consumer_version_tag_names.select{ |name| tags.include?(name) }
|
44
|
+
PactBroker::Domain::IndexItem.create pact.consumer, pact.provider, pact, true, latest_verification, webhooks, triggered_webhooks, tag_names
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.build_index_item_for_tagged_pact latest_pact, tag
|
48
|
+
pact = pact_service.find_latest_pact consumer_name: latest_pact.consumer_name, provider_name: latest_pact.provider_name, tag: tag
|
49
|
+
return nil unless pact
|
50
|
+
return nil if pact.id == latest_pact.id
|
51
|
+
verification = verification_repository.find_latest_verification_for pact.consumer_name, pact.provider_name, tag
|
52
|
+
PactBroker::Domain::IndexItem.create pact.consumer, pact.provider, pact, false, verification, [], [], [tag]
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'pact_broker/repositories'
|
2
2
|
require 'pact_broker/logging'
|
3
3
|
require 'pact_broker/messages'
|
4
|
-
require 'pact_broker/domain/relationship'
|
5
4
|
require 'pact_broker/pacticipants/find_potential_duplicate_pacticipant_names'
|
6
5
|
|
7
6
|
module PactBroker
|
@@ -58,17 +57,6 @@ module PactBroker
|
|
58
57
|
end
|
59
58
|
end
|
60
59
|
|
61
|
-
# This needs to move into a new service
|
62
|
-
def self.find_relationships
|
63
|
-
pact_repository.find_latest_pacts
|
64
|
-
.collect do | pact|
|
65
|
-
latest_verification = verification_service.find_latest_verification_for(pact.consumer, pact.provider)
|
66
|
-
webhooks = webhook_service.find_by_consumer_and_provider pact.consumer, pact.provider
|
67
|
-
triggered_webhooks = webhook_service.find_latest_triggered_webhooks pact.consumer, pact.provider
|
68
|
-
PactBroker::Domain::Relationship.create pact.consumer, pact.provider, pact, latest_verification, webhooks, triggered_webhooks
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
60
|
def self.update params
|
73
61
|
pacticipant = pacticipant_repository.find_by_name(params.fetch('name'))
|
74
62
|
PactBroker::Api::Decorators::PacticipantDecorator.new(pacticipant).from_hash(params)
|
@@ -86,7 +86,7 @@ module PactBroker
|
|
86
86
|
end
|
87
87
|
|
88
88
|
def find_latest_pacts
|
89
|
-
LatestPactPublications.order(:consumer_name, :provider_name).collect(&:
|
89
|
+
LatestPactPublications.order(:consumer_name, :provider_name).collect(&:to_domain)
|
90
90
|
end
|
91
91
|
|
92
92
|
def find_latest_pact(consumer_name, provider_name, tag = nil)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'pact_broker/domain/group'
|
2
2
|
|
3
3
|
=begin
|
4
|
-
Splits all
|
4
|
+
Splits all index_items up into groups of non-connecting index_items.
|
5
5
|
=end
|
6
6
|
|
7
7
|
module PactBroker
|
@@ -10,21 +10,21 @@ module PactBroker
|
|
10
10
|
|
11
11
|
class Groupify
|
12
12
|
|
13
|
-
def self.call
|
14
|
-
recurse_groups([],
|
13
|
+
def self.call index_items
|
14
|
+
recurse_groups([], index_items.dup).collect { |group| Domain::Group.new(group) }
|
15
15
|
end
|
16
16
|
|
17
|
-
def self.recurse_groups groups,
|
18
|
-
if
|
17
|
+
def self.recurse_groups groups, index_item_pool
|
18
|
+
if index_item_pool.empty?
|
19
19
|
groups
|
20
20
|
else
|
21
|
-
first, *rest =
|
21
|
+
first, *rest = index_item_pool
|
22
22
|
group = [first]
|
23
23
|
new_connections = true
|
24
24
|
while new_connections
|
25
25
|
new_connections = false
|
26
26
|
group = rest.inject(group) do |connected, candidate|
|
27
|
-
if connected.select { |
|
27
|
+
if connected.select { |index_item| index_item.connected?(candidate) }.any?
|
28
28
|
new_connections = true
|
29
29
|
connected + [candidate]
|
30
30
|
else
|
@@ -36,7 +36,7 @@ module PactBroker
|
|
36
36
|
group.uniq
|
37
37
|
end
|
38
38
|
|
39
|
-
recurse_groups(groups + [group],
|
39
|
+
recurse_groups(groups + [group], index_item_pool - group)
|
40
40
|
end
|
41
41
|
end
|
42
42
|
end
|
data/lib/pact_broker/services.rb
CHANGED
@@ -15,7 +15,7 @@ module PactBroker
|
|
15
15
|
def find args
|
16
16
|
PactBroker::Domain::Tag
|
17
17
|
.select_all_qualified
|
18
|
-
.join(:versions, {id: :version_id})
|
18
|
+
.join(:versions, { id: :version_id })
|
19
19
|
.join(:pacticipants, {Sequel.qualify("pacticipants", "id") => Sequel.qualify("versions", "pacticipant_id")})
|
20
20
|
.where(name_like(Sequel.qualify("tags", "name"), args.fetch(:tag_name)))
|
21
21
|
.where(name_like(Sequel.qualify("versions", "number"), args.fetch(:pacticipant_version_number)))
|
@@ -26,6 +26,16 @@ module PactBroker
|
|
26
26
|
def delete_by_version_id version_id
|
27
27
|
Sequel::Model.db[:tags].where(version_id: version_id).delete
|
28
28
|
end
|
29
|
+
|
30
|
+
def find_all_tag_names_for_pacticipant pacticipant_name
|
31
|
+
PactBroker::Domain::Tag
|
32
|
+
.select(Sequel[:tags][:name])
|
33
|
+
.join(:versions, { Sequel[:versions][:id] => Sequel[:tags][:version_id] })
|
34
|
+
.join(:pacticipants, { Sequel[:pacticipants][:id] => Sequel[:versions][:pacticipant_id] })
|
35
|
+
.where(Sequel[:pacticipants][:name] => pacticipant_name)
|
36
|
+
.distinct
|
37
|
+
.collect{ |tag| tag[:name] }.sort
|
38
|
+
end
|
29
39
|
end
|
30
40
|
end
|
31
41
|
end
|
@@ -25,7 +25,9 @@ module PactBroker
|
|
25
25
|
connection.run("delete from tags where name = '#{args.fetch(:tag_name)}' and version_id = '#{version.id}'")
|
26
26
|
end
|
27
27
|
|
28
|
+
def find_all_tag_names_for_pacticipant pacticipant_name
|
29
|
+
tag_repository.find_all_tag_names_for_pacticipant pacticipant_name
|
30
|
+
end
|
28
31
|
end
|
29
32
|
end
|
30
|
-
|
31
33
|
end
|
data/lib/pact_broker/ui/app.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'pact_broker/ui/controllers/
|
1
|
+
require 'pact_broker/ui/controllers/index'
|
2
2
|
require 'pact_broker/ui/controllers/groups'
|
3
3
|
require 'pact_broker/ui/controllers/matrix'
|
4
4
|
require 'pact_broker/doc/controllers/app'
|
@@ -11,7 +11,7 @@ module PactBroker
|
|
11
11
|
@app = ::Rack::Builder.new {
|
12
12
|
|
13
13
|
map "/ui/relationships" do
|
14
|
-
run PactBroker::UI::Controllers::
|
14
|
+
run PactBroker::UI::Controllers::Index
|
15
15
|
end
|
16
16
|
|
17
17
|
map "/groups" do
|
@@ -27,7 +27,7 @@ module PactBroker
|
|
27
27
|
end
|
28
28
|
|
29
29
|
map "/" do
|
30
|
-
run PactBroker::UI::Controllers::
|
30
|
+
run PactBroker::UI::Controllers::Index
|
31
31
|
end
|
32
32
|
}
|
33
33
|
end
|
@@ -18,7 +18,7 @@ module PactBroker
|
|
18
18
|
end
|
19
19
|
|
20
20
|
get "/" do
|
21
|
-
view_model = ViewDomain::
|
21
|
+
view_model = ViewDomain::IndexItems.new(pacticipant_service.find_index_items)
|
22
22
|
haml 'clusters/show', locals: {relationships: view_model}
|
23
23
|
end
|
24
24
|
|