pact_broker-client 1.38.3 → 1.43.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/CHANGELOG.md +47 -0
- data/Gemfile +4 -0
- data/README.md +57 -18
- data/doc/pacts/markdown/Pact Broker Client - Pact Broker.md +182 -2
- data/example/scripts/publish-pact.sh +1 -1
- data/lib/pact_broker/client/backports.rb +9 -0
- data/lib/pact_broker/client/base_command.rb +95 -0
- data/lib/pact_broker/client/can_i_deploy.rb +20 -3
- data/lib/pact_broker/client/cli/broker.rb +41 -28
- data/lib/pact_broker/client/cli/custom_thor.rb +12 -0
- data/lib/pact_broker/client/cli/environment_commands.rb +70 -0
- data/lib/pact_broker/client/cli/pacticipant_commands.rb +44 -0
- data/lib/pact_broker/client/cli/record_deployment_long_desc.txt +0 -0
- data/lib/pact_broker/client/cli/version_selector_options_parser.rb +4 -0
- data/lib/pact_broker/client/colorize_notices.rb +31 -0
- data/lib/pact_broker/client/environments.rb +3 -0
- data/lib/pact_broker/client/environments/create_environment.rb +31 -0
- data/lib/pact_broker/client/environments/delete_environment.rb +27 -0
- data/lib/pact_broker/client/environments/describe_environment.rb +36 -0
- data/lib/pact_broker/client/environments/environment_command.rb +66 -0
- data/lib/pact_broker/client/environments/list_environments.rb +30 -0
- data/lib/pact_broker/client/environments/text_formatter.rb +30 -0
- data/lib/pact_broker/client/environments/update_environment.rb +31 -0
- data/lib/pact_broker/client/generate_display_name.rb +27 -0
- data/lib/pact_broker/client/hal/entity.rb +26 -3
- data/lib/pact_broker/client/hal/http_client.rb +11 -2
- data/lib/pact_broker/client/hal/link.rb +20 -0
- data/lib/pact_broker/client/hal/links.rb +15 -0
- data/lib/pact_broker/client/hal_client_methods.rb +9 -3
- data/lib/pact_broker/client/matrix.rb +4 -0
- data/lib/pact_broker/client/matrix/abbreviate_version_number.rb +15 -0
- data/lib/pact_broker/client/matrix/resource.rb +26 -1
- data/lib/pact_broker/client/matrix/text_formatter.rb +28 -17
- data/lib/pact_broker/client/pacticipants.rb +6 -0
- data/lib/pact_broker/client/pacticipants/create.rb +24 -34
- data/lib/pact_broker/client/pacticipants/list.rb +34 -0
- data/lib/pact_broker/client/pacticipants/text_formatter.rb +41 -0
- data/lib/pact_broker/client/pacts.rb +0 -1
- data/lib/pact_broker/client/publish_pacts.rb +94 -128
- data/lib/pact_broker/client/publish_pacts_the_old_way.rb +194 -0
- data/lib/pact_broker/client/string_refinements.rb +56 -0
- data/lib/pact_broker/client/tasks/publication_task.rb +3 -3
- data/lib/pact_broker/client/version.rb +1 -1
- data/lib/pact_broker/client/versions/record_deployment.rb +14 -38
- data/lib/pact_broker/client/versions/record_undeployment.rb +45 -68
- data/pact-broker-client.gemspec +2 -0
- data/script/approve-all.sh +6 -0
- data/script/publish-pact.sh +36 -5
- data/script/record-deployment.sh +1 -3
- data/script/record-undeployment.sh +4 -0
- data/spec/fixtures/approvals/can_i_deploy_ignore.approved.txt +13 -0
- data/spec/fixtures/approvals/describe_environment.approved.txt +7 -0
- data/spec/fixtures/approvals/list_environments.approved.txt +3 -0
- data/spec/fixtures/foo-bar.json +31 -0
- data/spec/lib/pact_broker/client/can_i_deploy_spec.rb +47 -5
- data/spec/lib/pact_broker/client/cli/broker_can_i_deploy_spec.rb +5 -5
- data/spec/lib/pact_broker/client/cli/broker_publish_spec.rb +36 -7
- data/spec/lib/pact_broker/client/cli/broker_run_webhook_commands_spec.rb +3 -3
- data/spec/lib/pact_broker/client/cli/version_selector_options_parser_spec.rb +21 -0
- data/spec/lib/pact_broker/client/environments/delete_environment_spec.rb +120 -0
- data/spec/lib/pact_broker/client/environments/describe_environment_spec.rb +89 -0
- data/spec/lib/pact_broker/client/environments/update_environment_spec.rb +167 -0
- data/spec/lib/pact_broker/client/generate_display_name_spec.rb +39 -0
- data/spec/lib/pact_broker/client/hal/entity_spec.rb +2 -2
- data/spec/lib/pact_broker/client/pacticipants/create_spec.rb +5 -2
- data/spec/lib/pact_broker/client/{publish_pacts_spec.rb → publish_pacts_the_old_way_spec.rb} +10 -9
- data/spec/lib/pact_broker/client/tasks/publication_task_spec.rb +18 -12
- data/spec/lib/pact_broker/client/versions/record_deployment_spec.rb +17 -24
- data/spec/pacts/pact_broker_client-pact_broker.json +197 -2
- data/spec/service_providers/create_environment_spec.rb +78 -0
- data/spec/service_providers/list_environments_spec.rb +77 -0
- data/spec/service_providers/pact_broker_client_create_version_spec.rb +4 -4
- data/spec/service_providers/pact_broker_client_matrix_ignore_spec.rb +98 -0
- data/spec/service_providers/pacticipants_create_spec.rb +5 -4
- data/spec/service_providers/publish_pacts_spec.rb +116 -0
- data/spec/service_providers/record_deployment_spec.rb +14 -11
- data/spec/spec_helper.rb +3 -1
- data/spec/support/approvals.rb +26 -0
- data/spec/support/shared_context.rb +6 -2
- metadata +86 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 62d6345d206920c405cd04c6a3984ac2d3de6ebc687283eb22f3400f7e51e7fa
|
4
|
+
data.tar.gz: 18e2425b5fb80db316beaf58977432316afe9a48cc508a619006c5e8a9ec59af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ec0cca0de9787d4493143c2a2d9f9512df1b800c978a274a58b0b14a9d8fd7fc6c87609d2c3dd7f6916273c6600b9ec11a98dc47b8ac614aa71843f97c48378
|
7
|
+
data.tar.gz: f0c96d94f6bcd765ac5ac20bbc4950f64b205555461bdc2ca0a7fcfbe5d57e704eea430a3ddf1b11e2b499a76d828a2fdb552b8ce5a03d56bb3b852378690a32
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,50 @@
|
|
1
|
+
<a name="v1.43.0"></a>
|
2
|
+
### v1.43.0 (2021-06-03)
|
3
|
+
|
4
|
+
#### Features
|
5
|
+
|
6
|
+
* enable --ignore option for can-i-deploy without a feature toggle ([bcc9dfe](/../../commit/bcc9dfe))
|
7
|
+
|
8
|
+
<a name="v1.42.0"></a>
|
9
|
+
### v1.42.0 (2021-05-31)
|
10
|
+
|
11
|
+
#### Features
|
12
|
+
|
13
|
+
* add list-pacticipants ([fc8ce3b](/../../commit/fc8ce3b))
|
14
|
+
* add --display-name to create-or-update-pacticipant ([76f323b](/../../commit/76f323b))
|
15
|
+
* add backtrace to error output when verbose is true ([abf1ef0](/../../commit/abf1ef0))
|
16
|
+
* add list-environments and describe-environment ([4472d48](/../../commit/4472d48))
|
17
|
+
* add delete-environment ([361eed1](/../../commit/361eed1))
|
18
|
+
* add update-environment command ([95276cd](/../../commit/95276cd))
|
19
|
+
* add create-environment command ([a9fab50](/../../commit/a9fab50))
|
20
|
+
|
21
|
+
#### Bug Fixes
|
22
|
+
|
23
|
+
* stop long values in columns from being truncated ([18063fd](/../../commit/18063fd))
|
24
|
+
|
25
|
+
<a name="v1.41.0"></a>
|
26
|
+
### v1.41.0 (2021-05-25)
|
27
|
+
|
28
|
+
#### Features
|
29
|
+
|
30
|
+
* update colours of pact publish output ([2a51e37](/../../commit/2a51e37))
|
31
|
+
|
32
|
+
<a name="v1.40.0"></a>
|
33
|
+
### v1.40.0 (2021-04-26)
|
34
|
+
|
35
|
+
#### Features
|
36
|
+
|
37
|
+
* use the pb:publish-contracts relation and endpoint to publish pacts ([19f1b0b](/../../commit/19f1b0b))
|
38
|
+
* update publish pacts command to use new 'all in one' contract publishing endpoint ([50dfb11](/../../commit/50dfb11))
|
39
|
+
|
40
|
+
<a name="v1.39.0"></a>
|
41
|
+
### v1.39.0 (2021-04-27)
|
42
|
+
|
43
|
+
#### Features
|
44
|
+
|
45
|
+
* publish pacts using the "all in one" endpoint (#86) ([3a1ea22](/../../commit/3a1ea22))
|
46
|
+
* provide a more helpful error message when the specified pact file does not exist ([29a7962](/../../commit/29a7962))
|
47
|
+
|
1
48
|
<a name="v1.38.3"></a>
|
2
49
|
### v1.38.3 (2021-04-08)
|
3
50
|
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -78,27 +78,48 @@ Usage:
|
|
78
78
|
pact-broker can-i-deploy -a, --pacticipant=PACTICIPANT -b, --broker-base-url=BROKER_BASE_URL
|
79
79
|
|
80
80
|
Options:
|
81
|
-
-a, --pacticipant=PACTICIPANT
|
82
|
-
|
83
|
-
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
81
|
+
-a, --pacticipant=PACTICIPANT
|
82
|
+
# The pacticipant name. Use once for each pacticipant being checked.
|
83
|
+
-e, [--version=VERSION]
|
84
|
+
# The pacticipant version. Must be entered after the --pacticipant that it relates to.
|
85
|
+
[--ignore=IGNORE]
|
86
|
+
# The pacticipant name to ignore. Use once for each pacticipant being ignored.
|
87
|
+
A specific version can be ignored by also specifying a --version after the pacticipant name option.
|
88
|
+
-l, [--latest=[TAG]]
|
89
|
+
# Use the latest pacticipant version. Optionally specify a TAG to use the
|
90
|
+
latest version with the specified tag.
|
91
|
+
[--to=TAG]
|
92
|
+
# This is too hard to explain in a short sentence. Look at the examples.
|
93
|
+
-o, [--output=OUTPUT]
|
94
|
+
# json or table
|
95
|
+
|
96
|
+
# Default: table
|
97
|
+
[--retry-while-unknown=TIMES]
|
98
|
+
# The number of times to retry while there is an unknown verification result
|
99
|
+
(ie. the provider verification is likely still running)
|
100
|
+
|
101
|
+
# Default: 0
|
102
|
+
[--retry-interval=SECONDS]
|
103
|
+
# The time between retries in seconds. Use in conjuction with --retry-while-unknown
|
104
|
+
|
105
|
+
# Default: 10
|
106
|
+
-b, --broker-base-url=BROKER_BASE_URL
|
107
|
+
# The base URL of the Pact Broker
|
108
|
+
-u, [--broker-username=BROKER_USERNAME]
|
109
|
+
# Pact Broker basic auth username
|
110
|
+
-p, [--broker-password=BROKER_PASSWORD]
|
111
|
+
# Pact Broker basic auth password
|
112
|
+
-k, [--broker-token=BROKER_TOKEN]
|
113
|
+
# Pact Broker bearer token
|
114
|
+
-v, [--verbose], [--no-verbose]
|
115
|
+
# Verbose output. Default: false
|
96
116
|
|
97
117
|
Description:
|
98
|
-
Returns exit code 0 or 1, indicating whether or not the specified pacticipant versions are
|
99
|
-
pact/verification details
|
118
|
+
Returns exit code 0 or 1, indicating whether or not the specified application (pacticipant) versions are
|
119
|
+
compatible (ie. safe to deploy). Prints out the relevant pact/verification details, indicating any
|
120
|
+
missing or failed verification results.
|
100
121
|
|
101
|
-
The environment variables PACT_BROKER_BASE_URL,
|
122
|
+
The environment variables PACT_BROKER_BASE_URL, PACT_BROKER_USERNAME and PACT_BROKER_PASSWORD may be used
|
102
123
|
instead of their respective command line options.
|
103
124
|
```
|
104
125
|
|
@@ -309,6 +330,24 @@ Description:
|
|
309
330
|
the `generate-uuid` command.
|
310
331
|
```
|
311
332
|
|
333
|
+
### create-or-update-pacticipant
|
334
|
+
|
335
|
+
```
|
336
|
+
Usage:
|
337
|
+
pact-broker create-or-update-pacticipant --name=NAME -b, --broker-base-url=BROKER_BASE_URL
|
338
|
+
|
339
|
+
Options:
|
340
|
+
--name=NAME # Pacticipant name
|
341
|
+
[--repository-url=REPOSITORY_URL] # The repository URL of the pacticipant
|
342
|
+
-b, --broker-base-url=BROKER_BASE_URL # The base URL of the Pact Broker
|
343
|
+
-u, [--broker-username=BROKER_USERNAME] # Pact Broker basic auth username
|
344
|
+
-p, [--broker-password=BROKER_PASSWORD] # Pact Broker basic auth password
|
345
|
+
-k, [--broker-token=BROKER_TOKEN] # Pact Broker bearer token
|
346
|
+
-v, [--verbose], [--no-verbose] # Verbose output. Default: false
|
347
|
+
|
348
|
+
Create or update pacticipant by name
|
349
|
+
```
|
350
|
+
|
312
351
|
### describe-version
|
313
352
|
|
314
353
|
```
|
@@ -40,6 +40,8 @@
|
|
40
40
|
|
41
41
|
* [A request for the index resource](#a_request_for_the_index_resource_given_the_pb:pacticipant-version_relation_exists_in_the_index_resource) given the pb:pacticipant-version relation exists in the index resource
|
42
42
|
|
43
|
+
* [A request for the index resource](#a_request_for_the_index_resource_given_the_pb:publish-contracts_relations_exists_in_the_index_resource) given the pb:publish-contracts relations exists in the index resource
|
44
|
+
|
43
45
|
* [A request for the index resource with the webhook relation](#a_request_for_the_index_resource_with_the_webhook_relation)
|
44
46
|
|
45
47
|
* [A request for the list of the latest pacts from all consumers for the Pricing Service'](#a_request_for_the_list_of_the_latest_pacts_from_all_consumers_for_the_Pricing_Service'_given_a_latest_pact_between_Condor_and_the_Pricing_Service_exists) given a latest pact between Condor and the Pricing Service exists
|
@@ -74,6 +76,8 @@
|
|
74
76
|
|
75
77
|
* [A request to create a webhook with every possible event type](#a_request_to_create_a_webhook_with_every_possible_event_type_given_the_'Pricing_Service'_and_'Condor'_already_exist_in_the_pact-broker) given the 'Pricing Service' and 'Condor' already exist in the pact-broker
|
76
78
|
|
79
|
+
* [A request to determine if Bar can be deployed with all Foo tagged prod, ignoring the verification for Foo version 3.4.5](#a_request_to_determine_if_Bar_can_be_deployed_with_all_Foo_tagged_prod,_ignoring_the_verification_for_Foo_version_3.4.5_given_provider_Bar_version_4.5.6_has_a_successful_verification_for_Foo_version_1.2.3_tagged_prod_and_a_failed_verification_for_version_3.4.5_tagged_prod) given provider Bar version 4.5.6 has a successful verification for Foo version 1.2.3 tagged prod and a failed verification for version 3.4.5 tagged prod
|
80
|
+
|
77
81
|
* [A request to get the Pricing Service](#a_request_to_get_the_Pricing_Service_given_the_'Pricing_Service'_already_exists_in_the_pact-broker) given the 'Pricing Service' already exists in the pact-broker
|
78
82
|
|
79
83
|
* [A request to get the Pricing Service](#a_request_to_get_the_Pricing_Service_given_the_'Pricing_Service'_does_not_exist_in_the_pact-broker) given the 'Pricing Service' does not exist in the pact-broker
|
@@ -92,6 +96,8 @@
|
|
92
96
|
|
93
97
|
* [A request to publish a pact with method put](#a_request_to_publish_a_pact_with_method_put_given_the_'Pricing_Service'_and_'Condor'_already_exist_in_the_pact-broker,_and_Condor_already_has_a_pact_published_for_version_1.3.0) given the 'Pricing Service' and 'Condor' already exist in the pact-broker, and Condor already has a pact published for version 1.3.0
|
94
98
|
|
99
|
+
* [A request to publish contracts](#a_request_to_publish_contracts)
|
100
|
+
|
95
101
|
* [A request to record a deployment](#a_request_to_record_a_deployment_given_version_5556b8149bf8bac76bc30f50a8a2dd4c22c85f30_of_pacticipant_Foo_exists_with_a_test_environment_available_for_deployment) given version 5556b8149bf8bac76bc30f50a8a2dd4c22c85f30 of pacticipant Foo exists with a test environment available for deployment
|
96
102
|
|
97
103
|
* [A request to register the repository URL of a pacticipant](#a_request_to_register_the_repository_URL_of_a_pacticipant_given_the_'Pricing_Service'_already_exists_in_the_pact-broker) given the 'Pricing Service' already exists in the pact-broker
|
@@ -832,6 +838,33 @@ Pact Broker will respond with:
|
|
832
838
|
}
|
833
839
|
}
|
834
840
|
```
|
841
|
+
<a name="a_request_for_the_index_resource_given_the_pb:publish-contracts_relations_exists_in_the_index_resource"></a>
|
842
|
+
Given **the pb:publish-contracts relations exists in the index resource**, upon receiving **a request for the index resource** from Pact Broker Client, with
|
843
|
+
```json
|
844
|
+
{
|
845
|
+
"method": "GET",
|
846
|
+
"path": "/",
|
847
|
+
"headers": {
|
848
|
+
"Accept": "application/hal+json"
|
849
|
+
}
|
850
|
+
}
|
851
|
+
```
|
852
|
+
Pact Broker will respond with:
|
853
|
+
```json
|
854
|
+
{
|
855
|
+
"status": 200,
|
856
|
+
"headers": {
|
857
|
+
"Content-Type": "application/hal+json;charset=utf-8"
|
858
|
+
},
|
859
|
+
"body": {
|
860
|
+
"_links": {
|
861
|
+
"pb:publish-contracts": {
|
862
|
+
"href": "http://localhost:1234/HAL-REL-PLACEHOLDER-PB-PUBLISH-CONTRACTS"
|
863
|
+
}
|
864
|
+
}
|
865
|
+
}
|
866
|
+
}
|
867
|
+
```
|
835
868
|
<a name="a_request_for_the_index_resource_with_the_webhook_relation"></a>
|
836
869
|
Upon receiving **a request for the index resource with the webhook relation** from Pact Broker Client, with
|
837
870
|
```json
|
@@ -1576,6 +1609,83 @@ Pact Broker will respond with:
|
|
1576
1609
|
}
|
1577
1610
|
}
|
1578
1611
|
```
|
1612
|
+
<a name="a_request_to_determine_if_Bar_can_be_deployed_with_all_Foo_tagged_prod,_ignoring_the_verification_for_Foo_version_3.4.5_given_provider_Bar_version_4.5.6_has_a_successful_verification_for_Foo_version_1.2.3_tagged_prod_and_a_failed_verification_for_version_3.4.5_tagged_prod"></a>
|
1613
|
+
Given **provider Bar version 4.5.6 has a successful verification for Foo version 1.2.3 tagged prod and a failed verification for version 3.4.5 tagged prod**, upon receiving **a request to determine if Bar can be deployed with all Foo tagged prod, ignoring the verification for Foo version 3.4.5** from Pact Broker Client, with
|
1614
|
+
```json
|
1615
|
+
{
|
1616
|
+
"method": "get",
|
1617
|
+
"path": "/matrix",
|
1618
|
+
"query": "q%5B%5D%5Bpacticipant%5D=Bar&q%5B%5D%5Bversion%5D=4.5.6&q%5B%5D%5Bpacticipant%5D=Foo&q%5B%5D%5Btag%5D=prod&latestby=cvpv&ignore%5B%5D%5Bpacticipant%5D=Foo&ignore%5B%5D%5Bversion%5D=3.4.5"
|
1619
|
+
}
|
1620
|
+
```
|
1621
|
+
Pact Broker will respond with:
|
1622
|
+
```json
|
1623
|
+
{
|
1624
|
+
"status": 200,
|
1625
|
+
"headers": {
|
1626
|
+
"Content-Type": "application/hal+json;charset=utf-8"
|
1627
|
+
},
|
1628
|
+
"body": {
|
1629
|
+
"summary": {
|
1630
|
+
"deployable": true,
|
1631
|
+
"ignored": 1
|
1632
|
+
},
|
1633
|
+
"notices": [
|
1634
|
+
{
|
1635
|
+
"text": "some notice",
|
1636
|
+
"type": "info"
|
1637
|
+
}
|
1638
|
+
],
|
1639
|
+
"matrix": [
|
1640
|
+
{
|
1641
|
+
"consumer": {
|
1642
|
+
"name": "Foo",
|
1643
|
+
"version": {
|
1644
|
+
"number": "1.2.3"
|
1645
|
+
}
|
1646
|
+
},
|
1647
|
+
"provider": {
|
1648
|
+
"name": "Bar",
|
1649
|
+
"version": {
|
1650
|
+
"number": "4.5.6"
|
1651
|
+
}
|
1652
|
+
},
|
1653
|
+
"verificationResult": {
|
1654
|
+
"success": true,
|
1655
|
+
"_links": {
|
1656
|
+
"self": {
|
1657
|
+
"href": "http://result"
|
1658
|
+
}
|
1659
|
+
}
|
1660
|
+
}
|
1661
|
+
},
|
1662
|
+
{
|
1663
|
+
"consumer": {
|
1664
|
+
"name": "Foo",
|
1665
|
+
"version": {
|
1666
|
+
"number": "3.4.5"
|
1667
|
+
}
|
1668
|
+
},
|
1669
|
+
"provider": {
|
1670
|
+
"name": "Bar",
|
1671
|
+
"version": {
|
1672
|
+
"number": "4.5.6"
|
1673
|
+
}
|
1674
|
+
},
|
1675
|
+
"verificationResult": {
|
1676
|
+
"success": false,
|
1677
|
+
"_links": {
|
1678
|
+
"self": {
|
1679
|
+
"href": "http://result"
|
1680
|
+
}
|
1681
|
+
}
|
1682
|
+
},
|
1683
|
+
"ignored": true
|
1684
|
+
}
|
1685
|
+
]
|
1686
|
+
}
|
1687
|
+
}
|
1688
|
+
```
|
1579
1689
|
<a name="a_request_to_get_the_Pricing_Service_given_the_'Pricing_Service'_already_exists_in_the_pact-broker"></a>
|
1580
1690
|
Given **the 'Pricing Service' already exists in the pact-broker**, upon receiving **a request to get the Pricing Service** from Pact Broker Client, with
|
1581
1691
|
```json
|
@@ -1928,6 +2038,76 @@ Pact Broker will respond with:
|
|
1928
2038
|
}
|
1929
2039
|
}
|
1930
2040
|
```
|
2041
|
+
<a name="a_request_to_publish_contracts"></a>
|
2042
|
+
Upon receiving **a request to publish contracts** from Pact Broker Client, with
|
2043
|
+
```json
|
2044
|
+
{
|
2045
|
+
"method": "POST",
|
2046
|
+
"path": "/HAL-REL-PLACEHOLDER-PB-PUBLISH-CONTRACTS",
|
2047
|
+
"headers": {
|
2048
|
+
"Content-Type": "application/json",
|
2049
|
+
"Accept": "application/hal+json"
|
2050
|
+
},
|
2051
|
+
"body": {
|
2052
|
+
"pacticipantName": "Foo",
|
2053
|
+
"pacticipantVersionNumber": "5556b8149bf8bac76bc30f50a8a2dd4c22c85f30",
|
2054
|
+
"branch": "main",
|
2055
|
+
"tags": [
|
2056
|
+
"dev"
|
2057
|
+
],
|
2058
|
+
"buildUrl": "http://build",
|
2059
|
+
"contracts": [
|
2060
|
+
{
|
2061
|
+
"consumerName": "Foo",
|
2062
|
+
"providerName": "Bar",
|
2063
|
+
"specification": "pact",
|
2064
|
+
"contentType": "application/json",
|
2065
|
+
"content": "eyJjb25zdW1lciI6eyJuYW1lIjoiRm9vIn0sInByb3ZpZGVyIjp7Im5hbWUiOiJCYXIifSwiaW50ZXJhY3Rpb25zIjpbeyJkZXNjcmlwdGlvbiI6ImFuIGV4YW1wbGUgcmVxdWVzdCIsInByb3ZpZGVyU3RhdGUiOiJhIHByb3ZpZGVyIHN0YXRlIiwicmVxdWVzdCI6eyJtZXRob2QiOiJHRVQiLCJwYXRoIjoiLyIsImhlYWRlcnMiOnt9fSwicmVzcG9uc2UiOnsic3RhdHVzIjoyMDAsImhlYWRlcnMiOnsiQ29udGVudC1UeXBlIjoiYXBwbGljYXRpb24vaGFsK2pzb24ifX19XSwibWV0YWRhdGEiOnsicGFjdFNwZWNpZmljYXRpb24iOnsidmVyc2lvbiI6IjIuMC4wIn19fQ==",
|
2066
|
+
"writeMode": "overwrite",
|
2067
|
+
"onConflict": "overwrite"
|
2068
|
+
}
|
2069
|
+
]
|
2070
|
+
}
|
2071
|
+
}
|
2072
|
+
```
|
2073
|
+
Pact Broker will respond with:
|
2074
|
+
```json
|
2075
|
+
{
|
2076
|
+
"status": 200,
|
2077
|
+
"headers": {
|
2078
|
+
"Content-Type": "application/hal+json;charset=utf-8"
|
2079
|
+
},
|
2080
|
+
"body": {
|
2081
|
+
"_embedded": {
|
2082
|
+
"pacticipant": {
|
2083
|
+
"name": "Foo"
|
2084
|
+
},
|
2085
|
+
"version": {
|
2086
|
+
"number": "5556b8149bf8bac76bc30f50a8a2dd4c22c85f30",
|
2087
|
+
"buildUrl": "http://build"
|
2088
|
+
}
|
2089
|
+
},
|
2090
|
+
"logs": [
|
2091
|
+
{
|
2092
|
+
"level": "info",
|
2093
|
+
"message": "some message"
|
2094
|
+
}
|
2095
|
+
],
|
2096
|
+
"_links": {
|
2097
|
+
"pb:pacticipant-version-tags": [
|
2098
|
+
{
|
2099
|
+
"name": "dev"
|
2100
|
+
}
|
2101
|
+
],
|
2102
|
+
"pb:contracts": [
|
2103
|
+
{
|
2104
|
+
"href": "http://some-pact"
|
2105
|
+
}
|
2106
|
+
]
|
2107
|
+
}
|
2108
|
+
}
|
2109
|
+
}
|
2110
|
+
```
|
1931
2111
|
<a name="a_request_to_record_a_deployment_given_version_5556b8149bf8bac76bc30f50a8a2dd4c22c85f30_of_pacticipant_Foo_exists_with_a_test_environment_available_for_deployment"></a>
|
1932
2112
|
Given **version 5556b8149bf8bac76bc30f50a8a2dd4c22c85f30 of pacticipant Foo exists with a test environment available for deployment**, upon receiving **a request to record a deployment** from Pact Broker Client, with
|
1933
2113
|
```json
|
@@ -1939,7 +2119,7 @@ Given **version 5556b8149bf8bac76bc30f50a8a2dd4c22c85f30 of pacticipant Foo exis
|
|
1939
2119
|
"Accept": "application/hal+json"
|
1940
2120
|
},
|
1941
2121
|
"body": {
|
1942
|
-
"
|
2122
|
+
"target": "blue"
|
1943
2123
|
}
|
1944
2124
|
}
|
1945
2125
|
```
|
@@ -1951,7 +2131,7 @@ Pact Broker will respond with:
|
|
1951
2131
|
"Content-Type": "application/hal+json;charset=utf-8"
|
1952
2132
|
},
|
1953
2133
|
"body": {
|
1954
|
-
"
|
2134
|
+
"target": "blue"
|
1955
2135
|
}
|
1956
2136
|
}
|
1957
2137
|
```
|
@@ -1,3 +1,3 @@
|
|
1
1
|
# assumes you've set PACT_BROKER_BASE_URL, PACT_BROKER_USERNAME and PACT_BROKER_PASSWORD already
|
2
2
|
|
3
|
-
bundle exec bin/pact-broker publish $(dirname "$0")/pact.json --consumer-app-version=1.0.0 --tag master
|
3
|
+
bundle exec bin/pact-broker publish $(dirname "$0")/pact.json --consumer-app-version=1.0.0 --tag master --verbose
|
@@ -10,4 +10,13 @@ class Hash
|
|
10
10
|
def compact!
|
11
11
|
reject! {|_key, value| value == nil}
|
12
12
|
end unless method_defined? :compact!
|
13
|
+
|
14
|
+
def except(*keys)
|
15
|
+
if keys.size > 4 && size > 4 # index if O(m*n) is big
|
16
|
+
h = {}
|
17
|
+
keys.each { |key| h[key] = true }
|
18
|
+
keys = h
|
19
|
+
end
|
20
|
+
reject { |key, _value| keys.include? key}
|
21
|
+
end unless method_defined? :except
|
13
22
|
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
require 'pact_broker/client/hal_client_methods'
|
2
|
+
require 'pact_broker/client/error'
|
3
|
+
require 'pact_broker/client/command_result'
|
4
|
+
require 'term/ansicolor'
|
5
|
+
require 'pact_broker/client/backports'
|
6
|
+
|
7
|
+
module PactBroker
|
8
|
+
module Client
|
9
|
+
class BaseCommand
|
10
|
+
include PactBroker::Client::HalClientMethods
|
11
|
+
|
12
|
+
def self.call(params, options, pact_broker_client_options)
|
13
|
+
new(params, options, pact_broker_client_options).call
|
14
|
+
end
|
15
|
+
|
16
|
+
def initialize(params, options, pact_broker_client_options)
|
17
|
+
@params = params
|
18
|
+
@options = options
|
19
|
+
@pact_broker_base_url = pact_broker_client_options.fetch(:pact_broker_base_url)
|
20
|
+
@pact_broker_client_options = pact_broker_client_options
|
21
|
+
end
|
22
|
+
|
23
|
+
def call
|
24
|
+
check_if_command_supported
|
25
|
+
do_call
|
26
|
+
rescue PactBroker::Client::Hal::ErrorResponseReturned => e
|
27
|
+
handle_http_error(e)
|
28
|
+
rescue PactBroker::Client::Error => e
|
29
|
+
handle_ruby_error(e)
|
30
|
+
rescue StandardError => e
|
31
|
+
handle_ruby_error(e, verbose?)
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
attr_reader :params, :options
|
37
|
+
attr_reader :pact_broker_base_url, :pact_broker_client_options
|
38
|
+
|
39
|
+
def handle_http_error(e)
|
40
|
+
message = if json_output?
|
41
|
+
body = e.entity.response.raw_body
|
42
|
+
(body.nil? || body == "") ? "{}" : body
|
43
|
+
else
|
44
|
+
red(e.message)
|
45
|
+
end
|
46
|
+
PactBroker::Client::CommandResult.new(false, message)
|
47
|
+
end
|
48
|
+
|
49
|
+
def handle_ruby_error(e, include_backtrace = false)
|
50
|
+
PactBroker::Client::CommandResult.new(false, error_message(e, include_backtrace))
|
51
|
+
end
|
52
|
+
|
53
|
+
def error_message(e, include_backtrace)
|
54
|
+
if json_output?
|
55
|
+
json_error_message(e, include_backtrace)
|
56
|
+
else
|
57
|
+
text_error_message(e, include_backtrace)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def json_error_message(e, include_backtrace)
|
62
|
+
error_hash = { message: e.message }
|
63
|
+
error_hash[:class] = e.class.name unless e.is_a?(PactBroker::Client::Error)
|
64
|
+
error_hash[:backtrace] = e.backtrace if include_backtrace
|
65
|
+
{ error: error_hash }.to_json
|
66
|
+
end
|
67
|
+
|
68
|
+
|
69
|
+
def text_error_message(e, include_backtrace)
|
70
|
+
maybe_backtrace = (include_backtrace ? "\n" + e.backtrace.join("\n") : "")
|
71
|
+
exception_message = e.is_a?(PactBroker::Client::Error) ? e.message : "#{e.class} - #{e.message}"
|
72
|
+
red(exception_message) + maybe_backtrace
|
73
|
+
end
|
74
|
+
|
75
|
+
def check_if_command_supported
|
76
|
+
end
|
77
|
+
|
78
|
+
def json_output?
|
79
|
+
options[:output] == "json"
|
80
|
+
end
|
81
|
+
|
82
|
+
def verbose?
|
83
|
+
options[:verbose]
|
84
|
+
end
|
85
|
+
|
86
|
+
def green(text)
|
87
|
+
::Term::ANSIColor.green(text)
|
88
|
+
end
|
89
|
+
|
90
|
+
def red(text)
|
91
|
+
::Term::ANSIColor.red(text)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|