pact_broker 1.3.2.rc1 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +21 -0
- data/README.md +76 -17
- data/db/migrations/16_add_pact_content_foreign_key_to_pacts.rb +6 -0
- data/db/migrations/migration_helper.rb +11 -1
- data/example/Gemfile +1 -1
- data/example/pact_broker_database.sqlite3 +0 -0
- data/lib/db.rb +1 -0
- data/lib/pact_broker/api.rb +11 -2
- data/lib/pact_broker/api/decorators.rb +1 -1
- data/lib/pact_broker/api/decorators/base_decorator.rb +3 -3
- data/lib/pact_broker/api/decorators/basic_pacticipant_decorator.rb +0 -1
- data/lib/pact_broker/api/decorators/embedded_tag_decorator.rb +26 -0
- data/lib/pact_broker/api/decorators/embedded_version_decorator.rb +20 -0
- data/lib/pact_broker/api/decorators/pact_collection_decorator.rb +9 -3
- data/lib/pact_broker/api/decorators/pact_decorator.rb +70 -6
- data/lib/pact_broker/api/decorators/pact_pacticipant_decorator.rb +2 -2
- data/lib/pact_broker/api/decorators/pacticipant_collection_decorator.rb +4 -28
- data/lib/pact_broker/api/decorators/pacticipant_decorator.rb +2 -2
- data/lib/pact_broker/api/decorators/representable_pact.rb +4 -1
- data/lib/pact_broker/api/decorators/tag_decorator.rb +24 -1
- data/lib/pact_broker/api/decorators/timestamps.rb +2 -2
- data/lib/pact_broker/api/decorators/version_decorator.rb +27 -3
- data/lib/pact_broker/api/decorators/webhooks_decorator.rb +1 -1
- data/lib/pact_broker/api/pact_broker_urls.rb +10 -3
- data/lib/pact_broker/api/resources/index.rb +5 -5
- data/lib/pact_broker/api/resources/pact_content_diff.rb +40 -0
- data/lib/pact_broker/api/resources/previous_distinct_pact_version.rb +39 -0
- data/lib/pact_broker/api/resources/version.rb +36 -0
- data/lib/pact_broker/app.rb +2 -2
- data/lib/pact_broker/date_helper.rb +93 -0
- data/lib/pact_broker/doc/controllers/app.rb +1 -1
- data/lib/pact_broker/doc/views/consumer.markdown +7 -0
- data/lib/pact_broker/doc/views/diff-previous-distinct.markdown +5 -0
- data/lib/pact_broker/doc/views/latest-pact-version.markdown +7 -0
- data/lib/pact_broker/doc/views/latest-pact-versions.markdown +5 -0
- data/lib/pact_broker/doc/views/pact-versions.markdown +3 -0
- data/lib/pact_broker/doc/views/pact-webhooks.markdown +50 -0
- data/lib/pact_broker/doc/views/pacticipants.markdown +2 -0
- data/lib/pact_broker/doc/views/provider.markdown +7 -0
- data/lib/pact_broker/doc/views/tag-prod-version.markdown +7 -0
- data/lib/pact_broker/doc/views/tag-version.markdown +4 -0
- data/lib/pact_broker/doc/views/webhooks.markdown +2 -0
- data/lib/pact_broker/domain/pact.rb +6 -1
- data/lib/pact_broker/domain/tag.rb +0 -1
- data/lib/pact_broker/locale/en.yml +37 -1
- data/lib/pact_broker/pacts/all_pacts.rb +8 -0
- data/lib/pact_broker/pacts/create_formatted_diff.rb +20 -0
- data/lib/pact_broker/pacts/diff.rb +105 -0
- data/lib/pact_broker/pacts/repository.rb +43 -7
- data/lib/pact_broker/repositories/version_repository.rb +1 -0
- data/lib/pact_broker/services.rb +6 -1
- data/lib/pact_broker/services/pact_service.rb +6 -0
- data/lib/pact_broker/services/version_service.rb +2 -2
- data/lib/pact_broker/ui.rb +8 -3
- data/lib/pact_broker/ui/app.rb +2 -1
- data/lib/pact_broker/ui/controllers/base_controller.rb +1 -1
- data/lib/pact_broker/ui/controllers/clusters.rb +1 -1
- data/lib/pact_broker/ui/views/relationships/show.haml +11 -4
- data/lib/pact_broker/version.rb +1 -1
- data/pact_broker.gemspec +6 -4
- data/public/images/doc-text.svg +1 -0
- data/public/stylesheets/relationships.css +43 -1
- data/script/publish-2.sh +3 -0
- data/script/publish.sh +3 -0
- data/spec/features/delete_pact_spec.rb +1 -1
- data/spec/features/get_diff.rb +52 -0
- data/spec/features/get_previous_distinct_version.rb +51 -0
- data/spec/features/get_version.rb +45 -0
- data/spec/features/publish_pact_spec.rb +1 -1
- data/spec/fixtures/a_consumer-a_provider-2.json +22 -0
- data/spec/fixtures/a_consumer-a_provider.json +22 -0
- data/spec/fixtures/consumer-provider.json +4 -3
- data/spec/integration/app_spec.rb +6 -1
- data/spec/lib/pact_broker/api/decorators/embedded_tag_decorator_spec.rb +40 -0
- data/spec/lib/pact_broker/api/decorators/embedded_version_decorator_spec.rb +39 -0
- data/spec/lib/pact_broker/api/decorators/pact_decorator_spec.rb +52 -10
- data/spec/lib/pact_broker/api/decorators/pact_version_decorator_spec.rb +9 -1
- data/spec/lib/pact_broker/api/decorators/pacticipant_collection_decorator_spec.rb +36 -0
- data/spec/lib/pact_broker/api/decorators/tag_decorator_spec.rb +57 -0
- data/spec/lib/pact_broker/api/decorators/version_decorator_spec.rb +49 -0
- data/spec/lib/pact_broker/api/decorators/webhooks_decorator_spec.rb +2 -2
- data/spec/lib/pact_broker/pacts/create_formatted_diff_spec.rb +33 -0
- data/spec/lib/pact_broker/pacts/diff_spec.rb +72 -0
- data/spec/lib/pact_broker/pacts/pact_params_spec.rb +2 -2
- data/spec/lib/pact_broker/pacts/repository_spec.rb +90 -0
- data/spec/lib/pact_broker/repositories/version_repository_spec.rb +10 -2
- data/spec/lib/pact_broker/ui/controllers/relationships_spec.rb +1 -1
- data/vendor/hal-browser/README.md +6 -0
- data/vendor/hal-browser/browser.html +5 -3
- data/vendor/hal-browser/js/hal.js +3 -0
- data/vendor/hal-browser/js/hal/resource.js +1 -0
- data/vendor/hal-browser/js/hal/views/embedded_resource.js +1 -0
- data/vendor/hal-browser/js/hal/views/query_uri_dialog.js +12 -2
- data/vendor/hal-browser/js/hal/views/resource.js +6 -1
- data/vendor/hal-browser/styles.css +10 -0
- data/vendor/hal-browser/vendor/js/{jquery-1.9.1.js → jquery-1.10.2.js} +4394 -4202
- data/vendor/hal-browser/vendor/js/jquery-1.10.2.min.js +6 -0
- data/vendor/hal-browser/vendor/js/jquery-1.10.2.min.map +1 -0
- metadata +90 -18
- data/db/migrations/15_add_value_to_tag.rb.wip +0 -5
- data/lib/pact_broker/doc/views/latest-pacts.markdown +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 90724c609e603dd08b1bc686cbc8c46eeff7c030
|
4
|
+
data.tar.gz: b0b359476aea99b3738b802e8433441544d2add8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e027014136c6782da4f3ba31b0d3779b0bb2d55fff9f91ad8378d1644a3facf94630e129140f81c1ea61e628e616e0da4cd14d55c56c290e464bb53989835418
|
7
|
+
data.tar.gz: dbd9391992584cc6fddde02a8de3b15a5799b8a267db22947b3b48b50aa25a1e88d117c9b22a35d84a01a7260b4163843f3bdf010c696b223a747aaa47fe9eda
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,27 @@ Do this to generate your change history
|
|
2
2
|
|
3
3
|
$ git log --pretty=format:' * %h - %s (%an, %ad)'
|
4
4
|
|
5
|
+
#### 1.4.0 (2015-01-20)
|
6
|
+
|
7
|
+
* d740fb0 - Removed pact-versions rel from pact resource. Pact versions resource is not implemented yet. (Beth, Tue Jan 20 09:20:52 2015 +1100)
|
8
|
+
* bd6e63e - Handle case where there is no previous distinct version when displaying diff (Beth, Tue Jan 20 09:17:21 2015 +1100)
|
9
|
+
* d032ce1 - Changed pact icon on Pacts page to look more like a pact. (Beth, Wed Dec 24 09:58:35 2014 +1100)
|
10
|
+
* dbf67aa - Added endpoint for previous distinct pact version. (Beth, Mon Dec 22 14:08:07 2014 +1100)
|
11
|
+
* bde72f9 - Added migration to change pacts table to UTF8 (Beth, Mon Dec 22 11:45:09 2014 +1100)
|
12
|
+
* 8f587b7 - Modified pact HAL rels. (Beth, Mon Dec 22 11:41:10 2014 +1100)
|
13
|
+
* b813c0d - Renamed Relationships to Pacts. It was confusing. (Beth, Mon Dec 22 10:25:27 2014 +1100)
|
14
|
+
* 00d81aa - Changed diff resource to text/plain, added dates (Beth, Sun Dec 14 17:05:18 2014 +1100)
|
15
|
+
* 8f05772 - Set timezone to utc for test db connection (Beth, Sun Dec 14 17:04:16 2014 +1100)
|
16
|
+
* 407fa74 - Added link from HAL browser to home (Beth, Sat Dec 13 19:54:53 2014 +1100)
|
17
|
+
* a62faa9 - Adding missing docs (Beth, Sat Dec 13 19:51:36 2014 +1100)
|
18
|
+
* ec04e77 - Added HAL link to diff with previous distinct version (Beth, Fri Dec 12 08:31:12 2014 +1100)
|
19
|
+
* fe5f1d6 - Added endpoint to see the diff between a pact and the previous distinct version. (Beth, Thu Dec 11 17:35:22 2014 +1100)
|
20
|
+
* f802641 - Added version endpoint. (Beth, Wed Dec 10 13:06:13 2014 +1100)
|
21
|
+
* 715f49d - Force documentation window in HAL browser to be longer. This used to display correctly, but has somehow become quite short. Don't know what changed. (Beth, Tue Dec 9 18:47:53 2014 +1100)
|
22
|
+
* 25e612b - Removed curie from self links (Beth, Wed Dec 3 21:14:23 2014 +1100)
|
23
|
+
* 5cc922e - Added script to publish test pact. (Beth, Wed Dec 3 20:26:31 2014 +1100)
|
24
|
+
* f468b2c - Changed Padrino to log to stdout. :null creates a StringIO, don't want to hog memory. (Beth, Wed Dec 3 20:25:05 2014 +1100)
|
25
|
+
|
5
26
|
#### 1.3.2.rc1 (2014-12-03)
|
6
27
|
|
7
28
|
* a2413f4 - Stop Padrino trying to create a log file in the gem directory https://github.com/bethesque/pact_broker/issues/13 (Beth, Wed Dec 3 13:16:06 2014 +1100)
|
data/README.md
CHANGED
@@ -1,44 +1,103 @@
|
|
1
1
|
# Pact Broker
|
2
2
|
|
3
|
-
The Pact Broker provides a repository for
|
3
|
+
The Pact Broker provides a repository for consumer driven contracts created using the pact gem.
|
4
|
+
|
5
|
+
It:
|
6
|
+
|
7
|
+
* solves the problem of how to share pacts between consumer and provider projects
|
8
|
+
* allows you to [decouple your service release cycles][decouple]
|
9
|
+
* provides API documentation that is guaranteed to be up-to date
|
10
|
+
* shows you real examples of how your services interact
|
11
|
+
* allows you to visualise the relationships between your services
|
12
|
+
|
13
|
+
Features:
|
14
|
+
|
15
|
+
* A RESTful API for publishing and retrieving pacts.
|
16
|
+
* An embedded HAL browser for navigating the API.
|
17
|
+
* Autogenerated documentation for each pact.
|
18
|
+
* Dynamically generated network diagrams.
|
19
|
+
* Enables a pact version to be tagged (ie. "prod") so a provider can verify itself against a fixed version of a pact to ensure backwards compatibility.
|
20
|
+
* Webhooks to trigger a provider build when a consumer publishes a change to a pact.
|
4
21
|
|
5
22
|
Travis CI Status: [![Build Status](https://travis-ci.org/bethesque/pact_broker.svg?branch=master)](https://travis-ci.org/bethesque/pact_broker)
|
6
23
|
|
7
|
-
|
24
|
+
### How would I use the Pact Broker?
|
25
|
+
|
26
|
+
#### Step 1. Consumer CI build
|
27
|
+
1. The consumer project runs its tests using the [Pact][pact] library to provide a mock service.
|
28
|
+
2. While the tests run, the mock service writes the requests and the expected responses to a JSON "pact" file - this is the consumer contract.
|
29
|
+
3. The generated pact is then published to the Pact Broker. This is simply a PUT to a resource that specifies the consumer name and version, and the provider name. eg `http://my-pact-broker/pacts/provider/Animal%20Service/consumer/Zoo%20App/version/1.0.0`
|
30
|
+
|
31
|
+
#### Step 2. Provider CI build
|
32
|
+
1. The provider has a verification task that is configured with the URL to retrieve the dynamically calculated latest pact between itself and the consumer. eg `http://my-pact-broker/pacts/provider/Animal%20Service/consumer/Zoo%20App/latest`. The "latest" version is determined by the Pact Broker by inspecting the consumer version number specified when each pact was published.
|
33
|
+
2. The provider build runs the pact verification task, which retrieves the pact from the Pact Broker, replays each request against the provider, and checks that the responses match the expected responses.
|
34
|
+
3. If the pact verification fails, the build fails. The [Pact Broker CI Nerf Gun][nerf] magically determines who caused the verification to fail, and shoots them.
|
8
35
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
* Provides webhooks to trigger a provider build when a consumer publishes a change to a pact.
|
13
|
-
* Displays dynamically generated network diagrams.
|
36
|
+
If you don't have a [Pact Broker CI Nerf Gun][nerf], you'll probably want to read about using pact when the consumer and provider are being written by [different teams][different-teams].
|
37
|
+
|
38
|
+
## Documentation
|
14
39
|
|
15
40
|
See the [Pact Broker Client](https://github.com/bethesque/pact_broker-client) for documentation on how to publish a pact to the Pact Broker, and configure the URLs in the provider project.
|
16
41
|
|
42
|
+
See the [wiki](https://github.com/bethesque/pact_broker/wiki) for documentation related to the Pact Broker itself.
|
43
|
+
|
17
44
|
### Screenshots
|
18
45
|
|
19
46
|
#### Index
|
47
|
+
|
48
|
+
* * *
|
20
49
|
<img src="https://raw.githubusercontent.com/wiki/bethesque/pact_broker/images/index.png"/>
|
21
50
|
|
22
51
|
#### Autogenerated documentation
|
52
|
+
|
53
|
+
Paste the pact URL into a browser to view a HTML version of the pact.
|
54
|
+
* * *
|
23
55
|
<img src="https://raw.githubusercontent.com/wiki/bethesque/pact_broker/images/autogenerated_documentation.png"/>
|
24
56
|
|
57
|
+
|
25
58
|
#### Network diagram
|
59
|
+
|
60
|
+
* * *
|
26
61
|
<img src="https://raw.githubusercontent.com/wiki/bethesque/pact_broker/images/network_diagram.png"/>
|
27
62
|
|
28
|
-
|
63
|
+
#### HAL browser
|
29
64
|
|
30
|
-
|
65
|
+
Use the embedded HAL browser to nagivate the API.
|
66
|
+
* * *
|
67
|
+
<img src="https://raw.githubusercontent.com/wiki/bethesque/pact_broker/images/hal_browser.png"/>
|
68
|
+
|
69
|
+
#### HAL documentation
|
70
|
+
|
71
|
+
Use the HAL browser to view documentation as you browse.
|
72
|
+
* * *
|
73
|
+
<img src="https://raw.githubusercontent.com/wiki/bethesque/pact_broker/images/hal_documentation.png"/>
|
31
74
|
|
32
75
|
## Usage
|
33
76
|
|
34
|
-
|
35
|
-
|
77
|
+
### To have a play around on your local machine
|
78
|
+
|
36
79
|
* Install ruby 1.9.3 or later
|
37
|
-
*
|
38
|
-
* Modify the config.ru and Gemfile as desired (eg. choose database driver gem, set your database credentials)
|
39
|
-
* Please ensure you use `encoding: 'utf8'` in your Sequel options to avoid encoding issues.
|
80
|
+
* Run `git clone git@github.com:bethesque/pact_broker.git && cd pact_broker/example`
|
40
81
|
* Run `bundle`
|
41
|
-
* Run `bundle exec rackup`
|
42
|
-
* Open [http://localhost:
|
82
|
+
* Run `bundle exec rackup -p 8080`
|
83
|
+
* Open [http://localhost:8080](http://localhost:8080) and you should see a list containing the pact between the Zoo App and the Animal Service.
|
84
|
+
* Click on the arrow to see the generated HTML documentation.
|
85
|
+
* Click on either service to see an autogenerated network diagram.
|
86
|
+
* Click on the HAL Browser link to have a poke around the API.
|
87
|
+
* Click on the book icon under "docs" to view documentation related to a given relation.
|
88
|
+
|
89
|
+
### For reals
|
90
|
+
|
91
|
+
* Create a database using a product that is supported by the Sequel gem (listed on this page http://sequel.jeremyevans.net/rdoc/files/README_rdoc.html). The migrations have been tested on MySQL and PostgreSQL - your milage will vary on other databases.
|
92
|
+
* __Note:__ It is recommended to use __PostgreSQL__ as it will support JSON search features that are planned in a future release, however MySQL the other well supported database.
|
93
|
+
* Install ruby 1.9.3 or later
|
94
|
+
* Copy the [example](/example) directory to the location you want to install the application.
|
95
|
+
* Modify the config.ru and Gemfile as desired (eg. choose database driver gem, set your database credentials. Use the "pg" gem if using Postgres.)
|
96
|
+
* Please ensure you use `encoding: 'utf8'` in your Sequel options to avoid encoding issues.
|
97
|
+
* For production usage, use a web application server like [Phusion Passenger](https://www.phusionpassenger.com) or [Nginx][http://nginx.org/] to serve the Pact Broker application.
|
98
|
+
* Deploy to your location of choice.
|
43
99
|
|
44
|
-
|
100
|
+
[decouple]: http://techblog.realestate.com.au/enter-the-pact-matrix-or-how-to-decouple-the-release-cycles-of-your-microservices/
|
101
|
+
[pact]: https://github.com/realestate-com-au/pact
|
102
|
+
[nerf]: https://github.com/bethesque/pact_broker/wiki/pact-broker-ci-nerf-gun
|
103
|
+
[different-teams]: https://github.com/realestate-com-au/pact/wiki/Using-pact-where-the-consumer-team-is-different-from-the-provider-team
|
@@ -3,6 +3,12 @@ require_relative 'migration_helper'
|
|
3
3
|
|
4
4
|
Sequel.migration do
|
5
5
|
change do
|
6
|
+
|
7
|
+
PactBroker::MigrationHelper.with_mysql do
|
8
|
+
# Needed to make FK pact_version_content_sha match encoding of pact_version_content ID
|
9
|
+
run("ALTER TABLE pacts CONVERT TO CHARACTER SET 'utf8';")
|
10
|
+
end
|
11
|
+
|
6
12
|
alter_table(:pacts) do
|
7
13
|
add_foreign_key :pact_version_content_sha, :pact_version_contents, type: String, null: true, foreign_key_constraint_name: 'fk_pact_version_content'
|
8
14
|
end
|
@@ -4,12 +4,22 @@ module PactBroker
|
|
4
4
|
extend self
|
5
5
|
|
6
6
|
def large_text_type
|
7
|
-
if
|
7
|
+
if adapter == 'postgres'
|
8
8
|
:text
|
9
9
|
else
|
10
10
|
# Assume mysql
|
11
11
|
:mediumtext
|
12
12
|
end
|
13
13
|
end
|
14
|
+
|
15
|
+
def with_mysql
|
16
|
+
if adapter =~ /mysql/
|
17
|
+
yield
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def adapter
|
22
|
+
Sequel::Model.db.adapter_scheme.to_s
|
23
|
+
end
|
14
24
|
end
|
15
25
|
end
|
data/example/Gemfile
CHANGED
Binary file
|
data/lib/db.rb
CHANGED
@@ -28,6 +28,7 @@ module DB
|
|
28
28
|
con = Sequel.connect(db_credentials.merge(:logger => logger, :pool_class => Sequel::ThreadedConnectionPool))
|
29
29
|
con.extension(:connection_validator)
|
30
30
|
con.pool.connection_validation_timeout = -1 #Check the connection on every request
|
31
|
+
con.timezone = :utc
|
31
32
|
con
|
32
33
|
end
|
33
34
|
|
data/lib/pact_broker/api.rb
CHANGED
@@ -12,6 +12,10 @@ require 'pact_broker/api/resources/pact_versions'
|
|
12
12
|
require 'pact_broker/api/resources/webhooks'
|
13
13
|
require 'pact_broker/api/resources/webhook'
|
14
14
|
require 'pact_broker/api/resources/webhook_execution'
|
15
|
+
require 'pact_broker/api/resources/version'
|
16
|
+
require 'pact_broker/api/resources/pact_content_diff'
|
17
|
+
require 'pact_broker/api/resources/previous_distinct_pact_version'
|
18
|
+
|
15
19
|
|
16
20
|
require 'webmachine/adapters/rack'
|
17
21
|
|
@@ -23,15 +27,20 @@ module PactBroker
|
|
23
27
|
add(['trace', '*'], Webmachine::Trace::TraceResource) unless ENV['RACK_ENV'] == 'production'
|
24
28
|
# Support both /pact and /pacts
|
25
29
|
# /pact will be deprecated
|
30
|
+
# Todo, rename /version/ to /versions
|
26
31
|
add ['pacts', 'provider', :provider_name, 'consumer', :consumer_name, 'latest'], Api::Resources::LatestPact
|
27
32
|
add ['pacts', 'provider', :provider_name, 'consumer', :consumer_name, 'latest', :tag], Api::Resources::LatestPact
|
28
|
-
add ['pacts', 'provider', :provider_name, 'consumer', :consumer_name, 'version', :consumer_version_number], Api::Resources::Pact
|
29
|
-
add ['pacts', 'provider', :provider_name, 'consumer', :consumer_name, 'versions'], Api::Resources::
|
33
|
+
add ['pacts', 'provider', :provider_name, 'consumer', :consumer_name, 'version', :consumer_version_number], Api::Resources::Pact # Deprecate
|
34
|
+
add ['pacts', 'provider', :provider_name, 'consumer', :consumer_name, 'versions', :consumer_version_number], Api::Resources::Pact
|
35
|
+
add ['pacts', 'provider', :provider_name, 'consumer', :consumer_name, 'version', :consumer_version_number, 'previous-distinct'], Api::Resources::PreviousDistinctPactVersion
|
36
|
+
add ['pacts', 'provider', :provider_name, 'consumer', :consumer_name, 'version', :consumer_version_number, 'diff', 'previous-distinct'], Api::Resources::PactContentDiff
|
37
|
+
|
30
38
|
add ['pact', 'provider', :provider_name, 'consumer', :consumer_name, 'version', :consumer_version_number], Api::Resources::Pact
|
31
39
|
add ['pact', 'provider', :provider_name, 'consumer', :consumer_name, 'latest'], Api::Resources::LatestPact
|
32
40
|
add ['pacts', 'latest'], Api::Resources::LatestPacts
|
33
41
|
add ['pacticipants'], Api::Resources::Pacticipants
|
34
42
|
add ['pacticipants', :name], Api::Resources::Pacticipant
|
43
|
+
add ['pacticipants', :pacticipant_name, 'versions', :pacticipant_version_number], Api::Resources::Version
|
35
44
|
add ['pacticipants', :pacticipant_name, 'versions', :pacticipant_version_number, 'tags', :tag_name], Api::Resources::Tag
|
36
45
|
add ['relationships'], Api::Resources::Relationships
|
37
46
|
add ['groups', :pacticipant_name], Api::Resources::Group
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'pact_broker/api/decorators/pacticipant_decorator'
|
2
2
|
require 'pact_broker/api/decorators/pacticipant_collection_decorator'
|
3
|
-
require 'pact_broker/api/decorators/
|
3
|
+
require 'pact_broker/api/decorators/embedded_version_decorator'
|
4
4
|
require 'pact_broker/api/decorators/pact_collection_decorator'
|
5
5
|
require 'pact_broker/api/decorators/pact_pacticipant_decorator'
|
6
6
|
require 'pact_broker/api/decorators/pact_details_decorator'
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'roar/decorator'
|
2
|
-
require 'roar/
|
2
|
+
require 'roar/json/hal'
|
3
3
|
require 'pact_broker/api/pact_broker_urls'
|
4
4
|
require 'pact_broker/api/decorators/decorator_context'
|
5
5
|
|
@@ -10,8 +10,8 @@ module PactBroker
|
|
10
10
|
module Decorators
|
11
11
|
|
12
12
|
class BaseDecorator < Roar::Decorator
|
13
|
-
include Roar::
|
14
|
-
include Roar::
|
13
|
+
include Roar::JSON::HAL
|
14
|
+
include Roar::JSON::HAL::Links
|
15
15
|
include PactBroker::Api::PactBrokerUrls
|
16
16
|
end
|
17
17
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require_relative 'base_decorator'
|
2
|
+
require_relative 'pact_pacticipant_decorator'
|
3
|
+
require_relative 'timestamps'
|
4
|
+
|
5
|
+
module PactBroker
|
6
|
+
|
7
|
+
module Api
|
8
|
+
|
9
|
+
module Decorators
|
10
|
+
|
11
|
+
class EmbeddedTagDecorator < BaseDecorator
|
12
|
+
|
13
|
+
property :name
|
14
|
+
|
15
|
+
link :self do | options |
|
16
|
+
{
|
17
|
+
title: 'Tag',
|
18
|
+
name: represented.name,
|
19
|
+
href: tag_url(options[:base_url], represented)
|
20
|
+
}
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require_relative 'base_decorator'
|
2
|
+
|
3
|
+
module PactBroker
|
4
|
+
module Api
|
5
|
+
module Decorators
|
6
|
+
class EmbeddedVersionDecorator < BaseDecorator
|
7
|
+
|
8
|
+
property :number
|
9
|
+
|
10
|
+
link :self do | options |
|
11
|
+
{
|
12
|
+
title: 'Version',
|
13
|
+
name: represented.number,
|
14
|
+
href: version_url(options.fetch(:base_url), represented)
|
15
|
+
}
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require_relative 'base_decorator'
|
2
|
-
require_relative '
|
2
|
+
require_relative 'embedded_version_decorator'
|
3
3
|
require_relative 'latest_pact_decorator'
|
4
4
|
require_relative 'representable_pact'
|
5
5
|
|
@@ -10,7 +10,7 @@ module PactBroker
|
|
10
10
|
module Decorators
|
11
11
|
|
12
12
|
class PactCollectionDecorator < BaseDecorator
|
13
|
-
include Roar::
|
13
|
+
include Roar::JSON::HAL
|
14
14
|
include PactBroker::Api::PactBrokerUrls
|
15
15
|
|
16
16
|
collection :pacts, exec_context: :decorator, :class => PactBroker::Domain::Pact, :extend => PactBroker::Api::Decorators::LatestPactDecorator
|
@@ -29,7 +29,13 @@ module PactBroker
|
|
29
29
|
|
30
30
|
# This is the LATEST pact URL
|
31
31
|
links :pacts do | options |
|
32
|
-
represented.collect
|
32
|
+
represented.collect do | pact |
|
33
|
+
{
|
34
|
+
:href => latest_pact_url(options[:base_url], pact),
|
35
|
+
:name => "Latest pact between #{pact.consumer.name} and #{pact.provider.name}",
|
36
|
+
:title => "Pact"
|
37
|
+
}
|
38
|
+
end
|
33
39
|
end
|
34
40
|
|
35
41
|
end
|
@@ -16,28 +16,92 @@ module PactBroker
|
|
16
16
|
::JSON.parse(represented.json_content, PACT_PARSING_OPTIONS).merge super
|
17
17
|
end
|
18
18
|
|
19
|
-
link :
|
19
|
+
link :self do | options |
|
20
20
|
{
|
21
|
-
title:
|
21
|
+
title: 'Pact',
|
22
|
+
name: represented.name,
|
23
|
+
href: pact_url(options.fetch(:base_url), represented)
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
27
|
+
link :'pb:consumer' do | options |
|
28
|
+
{
|
29
|
+
title: "Consumer",
|
30
|
+
name: represented.consumer.name,
|
31
|
+
href: pacticipant_url(options.fetch(:base_url), represented.consumer)
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
link :'pb:provider' do | options |
|
36
|
+
{
|
37
|
+
title: "Provider",
|
38
|
+
name: represented.provider.name,
|
39
|
+
href: pacticipant_url(options.fetch(:base_url), represented.provider)
|
40
|
+
}
|
41
|
+
end
|
42
|
+
|
43
|
+
link :'pb:latest-pact-version' do | options |
|
44
|
+
{
|
45
|
+
title: "Pact",
|
46
|
+
name: "Latest version of this pact",
|
22
47
|
href: latest_pact_url(options.fetch(:base_url), represented)
|
23
48
|
|
24
49
|
}
|
25
50
|
end
|
26
51
|
|
27
|
-
link :'
|
52
|
+
link :'pb:previous-distinct' do | options |
|
53
|
+
{
|
54
|
+
title: "Pact",
|
55
|
+
name: "Previous distinct version of this pact",
|
56
|
+
href: previous_distinct_pact_version_url(represented, options.fetch(:base_url))
|
57
|
+
}
|
58
|
+
end
|
59
|
+
|
60
|
+
link :'pb:diff-previous-distinct' do | options |
|
28
61
|
{
|
29
|
-
title: "
|
30
|
-
|
62
|
+
title: "Diff",
|
63
|
+
name: "Diff with previous distinct version of this pact",
|
64
|
+
href: previous_distinct_diff_url(represented, options.fetch(:base_url))
|
65
|
+
|
31
66
|
}
|
32
67
|
end
|
33
68
|
|
34
|
-
link :'pact-
|
69
|
+
# link :'pb:pact-versions' do | options |
|
70
|
+
# {
|
71
|
+
# title: "All versions of the pact between #{represented.consumer.name} and #{represented.provider.name}",
|
72
|
+
# href: pact_versions_url(represented.consumer.name, represented.provider.name, options.fetch(:base_url))
|
73
|
+
# }
|
74
|
+
# end
|
75
|
+
|
76
|
+
link :'pb:pact-webhooks' do | options |
|
35
77
|
{
|
36
78
|
title: "Webhooks for the pact between #{represented.consumer.name} and #{represented.provider.name}",
|
37
79
|
href: webhooks_for_pact_url(represented.consumer, represented.provider, options.fetch(:base_url))
|
38
80
|
}
|
39
81
|
end
|
40
82
|
|
83
|
+
link :'pb:tag-prod-version' do | options |
|
84
|
+
{
|
85
|
+
title: "Tag this version as 'production'",
|
86
|
+
href: tags_url(options.fetch(:base_url), represented.consumer_version) + "/prod"
|
87
|
+
}
|
88
|
+
end
|
89
|
+
|
90
|
+
link :'pb:tag-version' do | options |
|
91
|
+
{
|
92
|
+
title: "Tag version",
|
93
|
+
href: tags_url(options.fetch(:base_url), represented.consumer_version) + "/{tag}"
|
94
|
+
}
|
95
|
+
end
|
96
|
+
|
97
|
+
curies do | options |
|
98
|
+
[{
|
99
|
+
name: :pb,
|
100
|
+
href: options[:base_url] + '/doc/{rel}',
|
101
|
+
templated: true
|
102
|
+
}]
|
103
|
+
end
|
104
|
+
|
41
105
|
end
|
42
106
|
end
|
43
107
|
end
|