pact_broker-client 1.35.0 → 1.38.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/release_gem.yml +1 -0
- data/CHANGELOG.md +34 -0
- data/Rakefile +2 -0
- data/doc/pacts/markdown/Pact Broker Client - Pact Broker.md +283 -0
- data/lib/pact_broker/client.rb +1 -1
- data/lib/pact_broker/client/backports.rb +13 -0
- data/lib/pact_broker/client/cli/broker.rb +112 -34
- data/lib/pact_broker/client/cli/can_i_deploy_long_desc.txt +18 -9
- data/lib/pact_broker/client/cli/create_or_update_webhook_long_desc.txt +3 -1
- data/lib/pact_broker/client/cli/create_webhook_long_desc.txt +2 -0
- data/lib/pact_broker/client/cli/custom_thor.rb +11 -17
- data/lib/pact_broker/client/git.rb +43 -22
- data/lib/pact_broker/client/hal/entity.rb +44 -3
- data/lib/pact_broker/client/hal/http_client.rb +5 -1
- data/lib/pact_broker/client/hal/links.rb +39 -0
- data/lib/pact_broker/client/hal_client_methods.rb +11 -0
- data/lib/pact_broker/client/hash_refinements.rb +19 -0
- data/lib/pact_broker/client/matrix.rb +2 -1
- data/lib/pact_broker/client/matrix/text_formatter.rb +2 -0
- data/lib/pact_broker/client/publish_pacts.rb +85 -14
- data/lib/pact_broker/client/tasks/publication_task.rb +37 -6
- data/lib/pact_broker/client/version.rb +1 -1
- data/lib/pact_broker/client/versions/record_deployment.rb +109 -0
- data/lib/pact_broker/client/versions/record_undeployment.rb +125 -0
- data/pact-broker-client.gemspec +1 -1
- data/script/publish-pact.sh +7 -1
- data/script/record-deployment.sh +4 -0
- data/script/trigger-release.sh +1 -1
- data/spec/lib/pact_broker/client/cli/broker_can_i_deploy_spec.rb +51 -6
- data/spec/lib/pact_broker/client/cli/broker_publish_spec.rb +108 -12
- data/spec/lib/pact_broker/client/cli/custom_thor_spec.rb +1 -7
- data/spec/lib/pact_broker/client/git_spec.rb +39 -2
- data/spec/lib/pact_broker/client/hal/entity_spec.rb +4 -3
- data/spec/lib/pact_broker/client/publish_pacts_spec.rb +99 -6
- data/spec/lib/pact_broker/client/tasks/publication_task_spec.rb +88 -10
- data/spec/lib/pact_broker/client/versions/describe_spec.rb +0 -1
- data/spec/lib/pact_broker/client/versions/record_deployment_spec.rb +82 -0
- data/spec/pacts/pact_broker_client-pact_broker.json +287 -0
- data/spec/service_providers/pact_broker_client_create_version_spec.rb +89 -0
- data/spec/service_providers/pact_broker_client_matrix_spec.rb +4 -0
- data/spec/service_providers/pact_broker_client_versions_spec.rb +1 -2
- data/spec/service_providers/record_deployment_spec.rb +219 -0
- data/spec/spec_helper.rb +2 -0
- data/tasks/pact.rake +2 -0
- metadata +19 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e1c89727fa660ba02fd9ff0565b74bf269aada75bfe3b04bb6f117048b265ad9
|
4
|
+
data.tar.gz: f6c946f2ab43c4cc69550b2fee0740a1782604e7843ae9b6a582664b6ecaee82
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a9f685a78726d293dc5017f1a142aa1d981a020ff8bdeafa56666a378562cd6c6632449c9ae980dff634e5c5ee216b3eb867b221156d15437166421b8eb1c14
|
7
|
+
data.tar.gz: 2ac71e6f98f361c1262e3190eb6e8b9ec588de4bb2ae51df6cd0e2bc8f44f4b5ee38270acb1ac670d772069eeaaaa1baea98ec34104c5fa9b91fa3ad5db315c3
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,37 @@
|
|
1
|
+
<a name="v1.38.1"></a>
|
2
|
+
### v1.38.1 (2021-03-22)
|
3
|
+
|
4
|
+
<a name="v1.38.0"></a>
|
5
|
+
### v1.38.0 (2021-03-22)
|
6
|
+
|
7
|
+
<a name="v1.37.1"></a>
|
8
|
+
### v1.37.1 (2021-03-11)
|
9
|
+
|
10
|
+
#### Bug Fixes
|
11
|
+
|
12
|
+
* set username from PACT_BROKER_USERNAME environment variable correctly when -u specified for create-or-update-webhook and create-webhook ([2411396](/../../commit/2411396))
|
13
|
+
|
14
|
+
<a name="v1.37.0"></a>
|
15
|
+
### v1.37.0 (2021-03-01)
|
16
|
+
|
17
|
+
#### Features
|
18
|
+
|
19
|
+
* add record-deployment ([6e5e208](/../../commit/6e5e208))
|
20
|
+
|
21
|
+
#### Bug Fixes
|
22
|
+
|
23
|
+
* use refinement to add compact to Hash ([c2c1cab](/../../commit/c2c1cab))
|
24
|
+
|
25
|
+
<a name="v1.36.0"></a>
|
26
|
+
### v1.36.0 (2021-02-21)
|
27
|
+
|
28
|
+
#### Features
|
29
|
+
|
30
|
+
* **can-i-deploy**
|
31
|
+
* add --to-environment option ([05ae44c](/../../commit/05ae44c))
|
32
|
+
|
33
|
+
* support version branch and build URL when publishing pacts ([a75f7df](/../../commit/a75f7df))
|
34
|
+
|
1
35
|
<a name="v1.35.0"></a>
|
2
36
|
### v1.35.0 (2021-01-21)
|
3
37
|
|
data/Rakefile
CHANGED
@@ -31,6 +31,8 @@ end
|
|
31
31
|
desc 'List provider states'
|
32
32
|
task 'pact:list_provider_states' do
|
33
33
|
require 'json'
|
34
|
+
require 'pact_broker/client/backports'
|
35
|
+
|
34
36
|
puts Dir.glob("spec/pacts/**.json").collect { | pact_file |
|
35
37
|
puts pact_file
|
36
38
|
JSON.parse(File.read(pact_file))['interactions'].collect{ | interaction| interaction['providerState'] }
|
@@ -2,6 +2,12 @@
|
|
2
2
|
|
3
3
|
#### Requests from Pact Broker Client to Pact Broker
|
4
4
|
|
5
|
+
* [A request for a pacticipant version](#a_request_for_a_pacticipant_version_given_version_5556b8149bf8bac76bc30f50a8a2dd4c22c85f30_of_pacticipant_Foo_exists_with_2_environments_that_aren't_test_available_for_deployment) given version 5556b8149bf8bac76bc30f50a8a2dd4c22c85f30 of pacticipant Foo exists with 2 environments that aren't test available for deployment
|
6
|
+
|
7
|
+
* [A request for a pacticipant version](#a_request_for_a_pacticipant_version_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
|
8
|
+
|
9
|
+
* [A request for a pacticipant version](#a_request_for_a_pacticipant_version_given_version_5556b8149bf8bac76bc30f50a8a2dd4c22c85f30_of_pacticipant_Foo_does_not_exist) given version 5556b8149bf8bac76bc30f50a8a2dd4c22c85f30 of pacticipant Foo does not exist
|
10
|
+
|
5
11
|
* [A request for the compatibility matrix for a pacticipant that does not exist](#a_request_for_the_compatibility_matrix_for_a_pacticipant_that_does_not_exist)
|
6
12
|
|
7
13
|
* [A request for the compatibility matrix for all versions of Foo and Bar](#a_request_for_the_compatibility_matrix_for_all_versions_of_Foo_and_Bar_given_the_pact_for_Foo_version_1.2.3_and_1.2.4_has_been_verified_by_Bar_version_4.5.6) given the pact for Foo version 1.2.3 and 1.2.4 has been verified by Bar version 4.5.6
|
@@ -20,6 +26,8 @@
|
|
20
26
|
|
21
27
|
* [A request for the compatibility matrix where only the version of Foo is specified](#a_request_for_the_compatibility_matrix_where_only_the_version_of_Foo_is_specified_given_the_pact_for_Foo_version_1.2.3_has_been_verified_by_Bar_version_4.5.6_and_version_5.6.7) given the pact for Foo version 1.2.3 has been verified by Bar version 4.5.6 and version 5.6.7
|
22
28
|
|
29
|
+
* [A request for the environments](#a_request_for_the_environments_given_an_environment_with_name_test_exists) given an environment with name test exists
|
30
|
+
|
23
31
|
* [A request for the index resource](#a_request_for_the_index_resource)
|
24
32
|
|
25
33
|
* [A request for the index resource](#a_request_for_the_index_resource_given_the_pacticipant_relations_are_present) given the pacticipant relations are present
|
@@ -28,6 +36,10 @@
|
|
28
36
|
|
29
37
|
* [A request for the index resource](#a_request_for_the_index_resource_given_the_pb:latest-version_relation_exists_in_the_index_resource) given the pb:latest-version relation exists in the index resource
|
30
38
|
|
39
|
+
* [A request for the index resource](#a_request_for_the_index_resource_given_the_pb:pacticipant-version_and_pb:environments_relations_exist_in_the_index_resource) given the pb:pacticipant-version and pb:environments relations exist in the index resource
|
40
|
+
|
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
|
+
|
31
43
|
* [A request for the index resource with the webhook relation](#a_request_for_the_index_resource_with_the_webhook_relation)
|
32
44
|
|
33
45
|
* [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
|
@@ -42,6 +54,10 @@
|
|
42
54
|
|
43
55
|
* [A request to create a pacticipant](#a_request_to_create_a_pacticipant)
|
44
56
|
|
57
|
+
* [A request to create a pacticipant version](#a_request_to_create_a_pacticipant_version_given_version_26f353580936ad3b9baddb17b00e84f33c69e7cb_of_pacticipant_Foo_does_exist) given version 26f353580936ad3b9baddb17b00e84f33c69e7cb of pacticipant Foo does exist
|
58
|
+
|
59
|
+
* [A request to create a pacticipant version](#a_request_to_create_a_pacticipant_version_given_version_26f353580936ad3b9baddb17b00e84f33c69e7cb_of_pacticipant_Foo_does_not_exist) given version 26f353580936ad3b9baddb17b00e84f33c69e7cb of pacticipant Foo does not exist
|
60
|
+
|
45
61
|
* [A request to create a webhook for a consumer and provider](#a_request_to_create_a_webhook_for_a_consumer_and_provider_given_'Condor'_does_not_exist_in_the_pact-broker) given 'Condor' does not exist in the pact-broker
|
46
62
|
|
47
63
|
* [A request to create a webhook with a JSON body and a uuid](#a_request_to_create_a_webhook_with_a_JSON_body_and_a_uuid_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,6 +92,8 @@
|
|
76
92
|
|
77
93
|
* [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
|
78
94
|
|
95
|
+
* [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
|
+
|
79
97
|
* [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
|
80
98
|
|
81
99
|
* [A request to register the repository URL of a pacticipant](#a_request_to_register_the_repository_URL_of_a_pacticipant_given_the_'Pricing_Service'_does_not_exist_in_the_pact-broker) given the 'Pricing Service' does not exist in the pact-broker
|
@@ -108,6 +126,87 @@
|
|
108
126
|
|
109
127
|
#### Interactions
|
110
128
|
|
129
|
+
<a name="a_request_for_a_pacticipant_version_given_version_5556b8149bf8bac76bc30f50a8a2dd4c22c85f30_of_pacticipant_Foo_exists_with_2_environments_that_aren't_test_available_for_deployment"></a>
|
130
|
+
Given **version 5556b8149bf8bac76bc30f50a8a2dd4c22c85f30 of pacticipant Foo exists with 2 environments that aren't test available for deployment**, upon receiving **a request for a pacticipant version** from Pact Broker Client, with
|
131
|
+
```json
|
132
|
+
{
|
133
|
+
"method": "GET",
|
134
|
+
"path": "/HAL-REL-PLACEHOLDER-PB-PACTICIPANT-VERSION-Foo-5556b8149bf8bac76bc30f50a8a2dd4c22c85f30",
|
135
|
+
"headers": {
|
136
|
+
"Accept": "application/hal+json"
|
137
|
+
}
|
138
|
+
}
|
139
|
+
```
|
140
|
+
Pact Broker will respond with:
|
141
|
+
```json
|
142
|
+
{
|
143
|
+
"status": 200,
|
144
|
+
"headers": {
|
145
|
+
"Content-Type": "application/hal+json;charset=utf-8"
|
146
|
+
},
|
147
|
+
"body": {
|
148
|
+
"_links": {
|
149
|
+
"pb:record-deployment": [
|
150
|
+
{
|
151
|
+
"name": "prod",
|
152
|
+
"href": "href"
|
153
|
+
},
|
154
|
+
{
|
155
|
+
"name": "dev",
|
156
|
+
"href": "href"
|
157
|
+
}
|
158
|
+
]
|
159
|
+
}
|
160
|
+
}
|
161
|
+
}
|
162
|
+
```
|
163
|
+
<a name="a_request_for_a_pacticipant_version_given_version_5556b8149bf8bac76bc30f50a8a2dd4c22c85f30_of_pacticipant_Foo_exists_with_a_test_environment_available_for_deployment"></a>
|
164
|
+
Given **version 5556b8149bf8bac76bc30f50a8a2dd4c22c85f30 of pacticipant Foo exists with a test environment available for deployment**, upon receiving **a request for a pacticipant version** from Pact Broker Client, with
|
165
|
+
```json
|
166
|
+
{
|
167
|
+
"method": "GET",
|
168
|
+
"path": "/HAL-REL-PLACEHOLDER-PB-PACTICIPANT-VERSION-Foo-5556b8149bf8bac76bc30f50a8a2dd4c22c85f30",
|
169
|
+
"headers": {
|
170
|
+
"Accept": "application/hal+json"
|
171
|
+
}
|
172
|
+
}
|
173
|
+
```
|
174
|
+
Pact Broker will respond with:
|
175
|
+
```json
|
176
|
+
{
|
177
|
+
"status": 200,
|
178
|
+
"headers": {
|
179
|
+
"Content-Type": "application/hal+json;charset=utf-8"
|
180
|
+
},
|
181
|
+
"body": {
|
182
|
+
"_links": {
|
183
|
+
"pb:record-deployment": [
|
184
|
+
{
|
185
|
+
"name": "test",
|
186
|
+
"href": "http://localhost:1234/HAL-REL-PLACEHOLDER-PB-RECORD-DEPLOYMENT-FOO-5556B8149BF8BAC76BC30F50A8A2DD4C22C85F30-TEST"
|
187
|
+
}
|
188
|
+
]
|
189
|
+
}
|
190
|
+
}
|
191
|
+
}
|
192
|
+
```
|
193
|
+
<a name="a_request_for_a_pacticipant_version_given_version_5556b8149bf8bac76bc30f50a8a2dd4c22c85f30_of_pacticipant_Foo_does_not_exist"></a>
|
194
|
+
Given **version 5556b8149bf8bac76bc30f50a8a2dd4c22c85f30 of pacticipant Foo does not exist**, upon receiving **a request for a pacticipant version** from Pact Broker Client, with
|
195
|
+
```json
|
196
|
+
{
|
197
|
+
"method": "GET",
|
198
|
+
"path": "/HAL-REL-PLACEHOLDER-PB-PACTICIPANT-VERSION-Foo-5556b8149bf8bac76bc30f50a8a2dd4c22c85f30",
|
199
|
+
"headers": {
|
200
|
+
"Accept": "application/hal+json"
|
201
|
+
}
|
202
|
+
}
|
203
|
+
```
|
204
|
+
Pact Broker will respond with:
|
205
|
+
```json
|
206
|
+
{
|
207
|
+
"status": 404
|
208
|
+
}
|
209
|
+
```
|
111
210
|
<a name="a_request_for_the_compatibility_matrix_for_a_pacticipant_that_does_not_exist"></a>
|
112
211
|
Upon receiving **a request for the compatibility matrix for a pacticipant that does not exist** from Pact Broker Client, with
|
113
212
|
```json
|
@@ -529,6 +628,36 @@ Pact Broker will respond with:
|
|
529
628
|
}
|
530
629
|
}
|
531
630
|
```
|
631
|
+
<a name="a_request_for_the_environments_given_an_environment_with_name_test_exists"></a>
|
632
|
+
Given **an environment with name test exists**, upon receiving **a request for the environments** from Pact Broker Client, with
|
633
|
+
```json
|
634
|
+
{
|
635
|
+
"method": "GET",
|
636
|
+
"path": "/HAL-REL-PLACEHOLDER-PB-ENVIRONMENTS",
|
637
|
+
"headers": {
|
638
|
+
"Accept": "application/hal+json"
|
639
|
+
}
|
640
|
+
}
|
641
|
+
```
|
642
|
+
Pact Broker will respond with:
|
643
|
+
```json
|
644
|
+
{
|
645
|
+
"status": 200,
|
646
|
+
"headers": {
|
647
|
+
"Content-Type": "application/hal+json;charset=utf-8"
|
648
|
+
},
|
649
|
+
"body": {
|
650
|
+
"_links": {
|
651
|
+
"pb:environments": [
|
652
|
+
{
|
653
|
+
"name": "test",
|
654
|
+
"href": "href"
|
655
|
+
}
|
656
|
+
]
|
657
|
+
}
|
658
|
+
}
|
659
|
+
}
|
660
|
+
```
|
532
661
|
<a name="a_request_for_the_index_resource"></a>
|
533
662
|
Upon receiving **a request for the index resource** from Pact Broker Client, with
|
534
663
|
```json
|
@@ -646,6 +775,63 @@ Pact Broker will respond with:
|
|
646
775
|
}
|
647
776
|
}
|
648
777
|
```
|
778
|
+
<a name="a_request_for_the_index_resource_given_the_pb:pacticipant-version_and_pb:environments_relations_exist_in_the_index_resource"></a>
|
779
|
+
Given **the pb:pacticipant-version and pb:environments relations exist in the index resource**, upon receiving **a request for the index resource** from Pact Broker Client, with
|
780
|
+
```json
|
781
|
+
{
|
782
|
+
"method": "GET",
|
783
|
+
"path": "/",
|
784
|
+
"headers": {
|
785
|
+
"Accept": "application/hal+json"
|
786
|
+
}
|
787
|
+
}
|
788
|
+
```
|
789
|
+
Pact Broker will respond with:
|
790
|
+
```json
|
791
|
+
{
|
792
|
+
"status": 200,
|
793
|
+
"headers": {
|
794
|
+
"Content-Type": "application/hal+json;charset=utf-8"
|
795
|
+
},
|
796
|
+
"body": {
|
797
|
+
"_links": {
|
798
|
+
"pb:pacticipant-version": {
|
799
|
+
"href": "http://localhost:1234/HAL-REL-PLACEHOLDER-PB-PACTICIPANT-VERSION-{pacticipant}-{version}"
|
800
|
+
},
|
801
|
+
"pb:environments": {
|
802
|
+
"href": "http://localhost:1234/HAL-REL-PLACEHOLDER-PB-ENVIRONMENTS"
|
803
|
+
}
|
804
|
+
}
|
805
|
+
}
|
806
|
+
}
|
807
|
+
```
|
808
|
+
<a name="a_request_for_the_index_resource_given_the_pb:pacticipant-version_relation_exists_in_the_index_resource"></a>
|
809
|
+
Given **the pb:pacticipant-version relation exists in the index resource**, upon receiving **a request for the index resource** from Pact Broker Client, with
|
810
|
+
```json
|
811
|
+
{
|
812
|
+
"method": "get",
|
813
|
+
"path": "/",
|
814
|
+
"headers": {
|
815
|
+
"Accept": "application/hal+json"
|
816
|
+
}
|
817
|
+
}
|
818
|
+
```
|
819
|
+
Pact Broker will respond with:
|
820
|
+
```json
|
821
|
+
{
|
822
|
+
"status": 200,
|
823
|
+
"headers": {
|
824
|
+
"Content-Type": "application/hal+json;charset=utf-8"
|
825
|
+
},
|
826
|
+
"body": {
|
827
|
+
"_links": {
|
828
|
+
"pb:pacticipant-version": {
|
829
|
+
"href": "http://localhost:1234/HAL-REL-PLACEHOLDER-INDEX-PB-PACTICIPANT-VERSION-{pacticipant}-{version}"
|
830
|
+
}
|
831
|
+
}
|
832
|
+
}
|
833
|
+
}
|
834
|
+
```
|
649
835
|
<a name="a_request_for_the_index_resource_with_the_webhook_relation"></a>
|
650
836
|
Upon receiving **a request for the index resource with the webhook relation** from Pact Broker Client, with
|
651
837
|
```json
|
@@ -898,6 +1084,76 @@ Pact Broker will respond with:
|
|
898
1084
|
}
|
899
1085
|
}
|
900
1086
|
```
|
1087
|
+
<a name="a_request_to_create_a_pacticipant_version_given_version_26f353580936ad3b9baddb17b00e84f33c69e7cb_of_pacticipant_Foo_does_exist"></a>
|
1088
|
+
Given **version 26f353580936ad3b9baddb17b00e84f33c69e7cb of pacticipant Foo does exist**, upon receiving **a request to create a pacticipant version** from Pact Broker Client, with
|
1089
|
+
```json
|
1090
|
+
{
|
1091
|
+
"method": "put",
|
1092
|
+
"path": "/HAL-REL-PLACEHOLDER-INDEX-PB-PACTICIPANT-VERSION-Foo-26f353580936ad3b9baddb17b00e84f33c69e7cb",
|
1093
|
+
"headers": {
|
1094
|
+
"Content-Type": "application/json",
|
1095
|
+
"Accept": "application/hal+json"
|
1096
|
+
},
|
1097
|
+
"body": {
|
1098
|
+
"branch": "main",
|
1099
|
+
"buildUrl": "http://my-ci/builds/1"
|
1100
|
+
}
|
1101
|
+
}
|
1102
|
+
```
|
1103
|
+
Pact Broker will respond with:
|
1104
|
+
```json
|
1105
|
+
{
|
1106
|
+
"status": 200,
|
1107
|
+
"headers": {
|
1108
|
+
"Content-Type": "application/hal+json;charset=utf-8"
|
1109
|
+
},
|
1110
|
+
"body": {
|
1111
|
+
"number": "26f353580936ad3b9baddb17b00e84f33c69e7cb",
|
1112
|
+
"branch": "main",
|
1113
|
+
"buildUrl": "http://my-ci/builds/1",
|
1114
|
+
"_links": {
|
1115
|
+
"self": {
|
1116
|
+
"href": "http://localhost:1234/some-url"
|
1117
|
+
}
|
1118
|
+
}
|
1119
|
+
}
|
1120
|
+
}
|
1121
|
+
```
|
1122
|
+
<a name="a_request_to_create_a_pacticipant_version_given_version_26f353580936ad3b9baddb17b00e84f33c69e7cb_of_pacticipant_Foo_does_not_exist"></a>
|
1123
|
+
Given **version 26f353580936ad3b9baddb17b00e84f33c69e7cb of pacticipant Foo does not exist**, upon receiving **a request to create a pacticipant version** from Pact Broker Client, with
|
1124
|
+
```json
|
1125
|
+
{
|
1126
|
+
"method": "put",
|
1127
|
+
"path": "/HAL-REL-PLACEHOLDER-INDEX-PB-PACTICIPANT-VERSION-Foo-26f353580936ad3b9baddb17b00e84f33c69e7cb",
|
1128
|
+
"headers": {
|
1129
|
+
"Content-Type": "application/json",
|
1130
|
+
"Accept": "application/hal+json"
|
1131
|
+
},
|
1132
|
+
"body": {
|
1133
|
+
"branch": "main",
|
1134
|
+
"buildUrl": "http://my-ci/builds/1"
|
1135
|
+
}
|
1136
|
+
}
|
1137
|
+
```
|
1138
|
+
Pact Broker will respond with:
|
1139
|
+
```json
|
1140
|
+
{
|
1141
|
+
"status": 201,
|
1142
|
+
"headers": {
|
1143
|
+
"Content-Type": "application/hal+json;charset=utf-8"
|
1144
|
+
},
|
1145
|
+
"body": {
|
1146
|
+
"number": "26f353580936ad3b9baddb17b00e84f33c69e7cb",
|
1147
|
+
"branch": "main",
|
1148
|
+
"buildUrl": "http://my-ci/builds/1",
|
1149
|
+
"_links": {
|
1150
|
+
"self": {
|
1151
|
+
"href": "http://localhost:1234/some-url"
|
1152
|
+
}
|
1153
|
+
}
|
1154
|
+
}
|
1155
|
+
}
|
1156
|
+
```
|
901
1157
|
<a name="a_request_to_create_a_webhook_for_a_consumer_and_provider_given_'Condor'_does_not_exist_in_the_pact-broker"></a>
|
902
1158
|
Given **'Condor' does not exist in the pact-broker**, upon receiving **a request to create a webhook for a consumer and provider** from Pact Broker Client, with
|
903
1159
|
```json
|
@@ -1672,6 +1928,33 @@ Pact Broker will respond with:
|
|
1672
1928
|
}
|
1673
1929
|
}
|
1674
1930
|
```
|
1931
|
+
<a name="a_request_to_record_a_deployment_given_version_5556b8149bf8bac76bc30f50a8a2dd4c22c85f30_of_pacticipant_Foo_exists_with_a_test_environment_available_for_deployment"></a>
|
1932
|
+
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
|
+
```json
|
1934
|
+
{
|
1935
|
+
"method": "POST",
|
1936
|
+
"path": "/HAL-REL-PLACEHOLDER-PB-RECORD-DEPLOYMENT-FOO-5556B8149BF8BAC76BC30F50A8A2DD4C22C85F30-TEST",
|
1937
|
+
"headers": {
|
1938
|
+
"Content-Type": "application/json",
|
1939
|
+
"Accept": "application/hal+json"
|
1940
|
+
},
|
1941
|
+
"body": {
|
1942
|
+
"replacedPreviousDeployedVersion": true
|
1943
|
+
}
|
1944
|
+
}
|
1945
|
+
```
|
1946
|
+
Pact Broker will respond with:
|
1947
|
+
```json
|
1948
|
+
{
|
1949
|
+
"status": 201,
|
1950
|
+
"headers": {
|
1951
|
+
"Content-Type": "application/hal+json;charset=utf-8"
|
1952
|
+
},
|
1953
|
+
"body": {
|
1954
|
+
"replacedPreviousDeployedVersion": true
|
1955
|
+
}
|
1956
|
+
}
|
1957
|
+
```
|
1675
1958
|
<a name="a_request_to_register_the_repository_URL_of_a_pacticipant_given_the_'Pricing_Service'_already_exists_in_the_pact-broker"></a>
|
1676
1959
|
Given **the 'Pricing Service' already exists in the pact-broker**, upon receiving **a request to register the repository URL of a pacticipant** from Pact Broker Client, with
|
1677
1960
|
```json
|
data/lib/pact_broker/client.rb
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
require 'pact_broker/client/version'
|
2
|
-
require 'pact_broker/client/pact_broker_client'
|
2
|
+
require 'pact_broker/client/pact_broker_client'
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'pact_broker/client/cli/custom_thor'
|
2
|
+
require 'pact_broker/client/hash_refinements'
|
2
3
|
require 'thor/error'
|
3
4
|
|
4
5
|
module PactBroker
|
@@ -11,6 +12,8 @@ module PactBroker
|
|
11
12
|
class VersionCreationError < ::Thor::Error; end
|
12
13
|
|
13
14
|
class Broker < CustomThor
|
15
|
+
using PactBroker::Client::HashRefinements
|
16
|
+
|
14
17
|
desc 'can-i-deploy', ''
|
15
18
|
long_desc File.read(File.join(File.dirname(__FILE__), 'can_i_deploy_long_desc.txt'))
|
16
19
|
|
@@ -18,16 +21,13 @@ module PactBroker
|
|
18
21
|
method_option :version, required: false, aliases: "-e", desc: "The pacticipant version. Must be entered after the --pacticipant that it relates to."
|
19
22
|
method_option :latest, required: false, aliases: "-l", banner: '[TAG]', desc: "Use the latest pacticipant version. Optionally specify a TAG to use the latest version with the specified tag."
|
20
23
|
method_option :to, required: false, banner: 'TAG', desc: "This is too hard to explain in a short sentence. Look at the examples.", default: nil
|
21
|
-
method_option :
|
22
|
-
method_option :broker_username, aliases: "-u", desc: "Pact Broker basic auth username"
|
23
|
-
method_option :broker_password, aliases: "-p", desc: "Pact Broker basic auth password"
|
24
|
-
method_option :broker_token, aliases: "-k", desc: "Pact Broker bearer token"
|
24
|
+
method_option :to_environment, required: false, banner: 'ENVIRONMENT', desc: "The environment into which the pacticipant(s) are to be deployed", default: nil, hide: true
|
25
25
|
method_option :output, aliases: "-o", desc: "json or table", default: 'table'
|
26
|
-
method_option :verbose, aliases: "-v", type: :boolean, default: false, required: false, desc: "Verbose output. Default: false"
|
27
26
|
method_option :retry_while_unknown, banner: 'TIMES', type: :numeric, default: 0, required: false, desc: "The number of times to retry while there is an unknown verification result (ie. the provider verification is likely still running)"
|
28
27
|
method_option :retry_interval, banner: 'SECONDS', type: :numeric, default: 10, required: false, desc: "The time between retries in seconds. Use in conjuction with --retry-while-unknown"
|
29
28
|
# Allow limit to be set manually until https://github.com/pact-foundation/pact_broker-client/issues/53 is fixed
|
30
29
|
method_option :limit, hide: true
|
30
|
+
shared_authentication_options
|
31
31
|
|
32
32
|
def can_i_deploy(*ignored_but_necessary)
|
33
33
|
require 'pact_broker/client/cli/version_selector_options_parser'
|
@@ -37,21 +37,20 @@ module PactBroker
|
|
37
37
|
selectors = VersionSelectorOptionsParser.call(ARGV)
|
38
38
|
validate_can_i_deploy_selectors(selectors)
|
39
39
|
can_i_deploy_options = { output: options.output, retry_while_unknown: options.retry_while_unknown, retry_interval: options.retry_interval }
|
40
|
-
result = CanIDeploy.call(options.broker_base_url, selectors, {to_tag: options.to, limit: options.limit}, can_i_deploy_options, pact_broker_client_options)
|
40
|
+
result = CanIDeploy.call(options.broker_base_url, selectors, { to_tag: options.to, to_environment: options.to_environment, limit: options.limit }, can_i_deploy_options, pact_broker_client_options)
|
41
41
|
$stdout.puts result.message
|
42
|
-
exit(
|
42
|
+
exit(can_i_deploy_exit_status) unless result.success
|
43
43
|
end
|
44
44
|
|
45
45
|
desc 'publish PACT_DIRS_OR_FILES ...', "Publish pacts to a Pact Broker."
|
46
46
|
method_option :consumer_app_version, required: true, aliases: "-a", desc: "The consumer application version"
|
47
|
-
method_option :
|
48
|
-
method_option :
|
49
|
-
method_option :broker_password, aliases: "-p", desc: "Pact Broker basic auth password"
|
50
|
-
method_option :broker_token, aliases: "-k", desc: "Pact Broker bearer token"
|
47
|
+
method_option :branch, aliases: "-h", desc: "Repository branch of the consumer version"
|
48
|
+
method_option :auto_detect_version_properties, hidden: true, type: :boolean, default: false, desc: "Automatically detect the repository branch from known CI environment variables or git CLI."
|
51
49
|
method_option :tag, aliases: "-t", type: :array, banner: "TAG", desc: "Tag name for consumer version. Can be specified multiple times."
|
52
50
|
method_option :tag_with_git_branch, aliases: "-g", type: :boolean, default: false, required: false, desc: "Tag consumer version with the name of the current git branch. Default: false"
|
51
|
+
method_option :build_url, desc: "The build URL that created the pact"
|
53
52
|
method_option :merge, type: :boolean, default: false, require: false, desc: "If a pact already exists for this consumer version and provider, merge the contents. Useful when running Pact tests concurrently on different build nodes."
|
54
|
-
|
53
|
+
shared_authentication_options
|
55
54
|
|
56
55
|
def publish(*pact_files)
|
57
56
|
require 'pact_broker/client/error'
|
@@ -69,11 +68,7 @@ module PactBroker
|
|
69
68
|
method_option :tag, aliases: "-t", type: :array, banner: "TAG", desc: "Tag name for pacticipant version. Can be specified multiple times."
|
70
69
|
method_option :auto_create_version, type: :boolean, default: false, desc: "Automatically create the pacticipant version if it does not exist. Default: false"
|
71
70
|
method_option :tag_with_git_branch, aliases: "-g", type: :boolean, default: false, required: false, desc: "Tag pacticipant version with the name of the current git branch. Default: false"
|
72
|
-
|
73
|
-
method_option :broker_username, aliases: "-u", desc: "Pact Broker basic auth username"
|
74
|
-
method_option :broker_password, aliases: "-p", desc: "Pact Broker basic auth password"
|
75
|
-
method_option :broker_token, aliases: "-k", desc: "Pact Broker bearer token"
|
76
|
-
method_option :verbose, aliases: "-v", type: :boolean, default: false, required: false, desc: "Verbose output. Default: false"
|
71
|
+
shared_authentication_options
|
77
72
|
|
78
73
|
def create_version_tag
|
79
74
|
require 'pact_broker/client/create_tag'
|
@@ -93,12 +88,8 @@ module PactBroker
|
|
93
88
|
method_option :pacticipant, required: true, aliases: "-a", desc: "The name of the pacticipant that the version belongs to."
|
94
89
|
method_option :version, required: false, aliases: "-e", desc: "The pacticipant version number."
|
95
90
|
method_option :latest, required: false, aliases: "-l", banner: '[TAG]', desc: "Describe the latest pacticipant version. Optionally specify a TAG to describe the latest version with the specified tag."
|
96
|
-
method_option :broker_base_url, required: true, aliases: "-b", desc: "The base URL of the Pact Broker"
|
97
|
-
method_option :broker_username, aliases: "-u", desc: "Pact Broker basic auth username"
|
98
|
-
method_option :broker_password, aliases: "-p", desc: "Pact Broker basic auth password"
|
99
|
-
method_option :broker_token, aliases: "-k", desc: "Pact Broker bearer token"
|
100
91
|
method_option :output, aliases: "-o", desc: "json or table or id", default: 'table'
|
101
|
-
|
92
|
+
shared_authentication_options
|
102
93
|
|
103
94
|
desc 'describe-version', 'Describes a pacticipant version. If no version or tag is specified, the latest version is described.'
|
104
95
|
def describe_version
|
@@ -139,7 +130,7 @@ module PactBroker
|
|
139
130
|
|
140
131
|
desc 'test-webhook', 'Test the execution of a webhook'
|
141
132
|
method_option :uuid, type: :string, required: true, desc: "Specify the uuid for the webhook"
|
142
|
-
|
133
|
+
shared_authentication_options
|
143
134
|
def test_webhook
|
144
135
|
require 'pact_broker/client/webhooks/test'
|
145
136
|
result = PactBroker::Client::Webhooks::Test.call(options, pact_broker_client_options)
|
@@ -157,7 +148,7 @@ module PactBroker
|
|
157
148
|
desc 'create-or-update-pacticipant', 'Create or update pacticipant by name'
|
158
149
|
method_option :name, type: :string, required: true, desc: "Pacticipant name"
|
159
150
|
method_option :repository_url, type: :string, required: false, desc: "The repository URL of the pacticipant"
|
160
|
-
|
151
|
+
shared_authentication_options
|
161
152
|
verbose_option
|
162
153
|
def create_or_update_pacticipant(*required_but_ignored)
|
163
154
|
raise ::Thor::RequiredArgumentMissingError, "Pacticipant name cannot be blank" if options.name.strip.size == 0
|
@@ -168,7 +159,7 @@ module PactBroker
|
|
168
159
|
end
|
169
160
|
|
170
161
|
desc 'list-latest-pact-versions', 'List the latest pact for each integration'
|
171
|
-
|
162
|
+
shared_authentication_options
|
172
163
|
method_option :output, aliases: "-o", desc: "json or table", default: 'table'
|
173
164
|
def list_latest_pact_versions(*required_but_ignored)
|
174
165
|
require 'pact_broker/client/pacts/list_latest_versions'
|
@@ -177,6 +168,62 @@ module PactBroker
|
|
177
168
|
exit(1) unless result.success
|
178
169
|
end
|
179
170
|
|
171
|
+
if ENV.fetch("PACT_BROKER_FEATURES", "").include?("deployments")
|
172
|
+
|
173
|
+
ignored_and_hidden_potential_options_from_environment_variables
|
174
|
+
desc "record-deployment", "Record deployment of a pacticipant version to an environment"
|
175
|
+
method_option :pacticipant, required: true, aliases: "-a", desc: "The name of the pacticipant that was deployed."
|
176
|
+
method_option :version, required: true, aliases: "-e", desc: "The pacticipant version number that was deployed."
|
177
|
+
method_option :environment, required: true, desc: "The name of the environment that the pacticipant version was deployed to."
|
178
|
+
method_option :replaced_previous_deployed_version, type: :boolean, default: true, required: false, desc: "Whether or not this deployment replaced the previous deployed version. If it did, the previous deployed version of this pacticipant will be marked as undeployed in the Pact Broker."
|
179
|
+
method_option :output, aliases: "-o", desc: "json or text", default: 'text'
|
180
|
+
shared_authentication_options
|
181
|
+
|
182
|
+
def record_deployment
|
183
|
+
require 'pact_broker/client/versions/record_deployment'
|
184
|
+
params = {
|
185
|
+
pacticipant_name: options.pacticipant,
|
186
|
+
version_number: options.version,
|
187
|
+
environment_name: options.environment,
|
188
|
+
replaced_previous_deployed_version: options.replaced_previous_deployed_version,
|
189
|
+
output: options.output
|
190
|
+
}
|
191
|
+
result = PactBroker::Client::Versions::RecordDeployment.call(
|
192
|
+
params,
|
193
|
+
options.broker_base_url,
|
194
|
+
pact_broker_client_options
|
195
|
+
)
|
196
|
+
$stdout.puts result.message
|
197
|
+
exit(1) unless result.success
|
198
|
+
end
|
199
|
+
|
200
|
+
ignored_and_hidden_potential_options_from_environment_variables
|
201
|
+
desc "record-undeployment", "Record undeployment of (or the end of support for) a pacticipant version from an environment"
|
202
|
+
method_option :pacticipant, required: true, aliases: "-a", desc: "The name of the pacticipant that was deployed."
|
203
|
+
method_option :version, required: true, aliases: "-e", desc: "The pacticipant version number that was deployed."
|
204
|
+
method_option :environment, required: true, desc: "The name of the environment that the pacticipant version was deployed to."
|
205
|
+
method_option :output, aliases: "-o", desc: "json or text", default: 'text'
|
206
|
+
shared_authentication_options
|
207
|
+
|
208
|
+
def record_undeployment
|
209
|
+
require 'pact_broker/client/versions/record_undeployment'
|
210
|
+
params = {
|
211
|
+
pacticipant_name: options.pacticipant,
|
212
|
+
version_number: options.version,
|
213
|
+
environment_name: options.environment,
|
214
|
+
output: options.output
|
215
|
+
}
|
216
|
+
result = PactBroker::Client::Versions::RecordUndeployment.call(
|
217
|
+
params,
|
218
|
+
options.broker_base_url,
|
219
|
+
pact_broker_client_options
|
220
|
+
)
|
221
|
+
$stdout.puts result.message
|
222
|
+
exit(1) unless result.success
|
223
|
+
end
|
224
|
+
|
225
|
+
end
|
226
|
+
|
180
227
|
ignored_and_hidden_potential_options_from_environment_variables
|
181
228
|
desc 'version', "Show the pact_broker-client gem version"
|
182
229
|
def version
|
@@ -191,6 +238,16 @@ module PactBroker
|
|
191
238
|
true
|
192
239
|
end
|
193
240
|
|
241
|
+
def can_i_deploy_exit_status
|
242
|
+
exit_code_string = ENV.fetch('PACT_BROKER_CAN_I_DEPLOY_EXIT_CODE_BETA', '')
|
243
|
+
if exit_code_string =~ /^\d+$/
|
244
|
+
$stderr.puts "Exiting can-i-deploy with configured exit code #{exit_code_string}"
|
245
|
+
exit_code_string.to_i
|
246
|
+
else
|
247
|
+
1
|
248
|
+
end
|
249
|
+
end
|
250
|
+
|
194
251
|
def validate_credentials
|
195
252
|
if options.broker_username && options.broker_token
|
196
253
|
raise AuthError, "You cannot provide both a username/password and a bearer token. If your Pact Broker uses a bearer token, please remove the username and password configuration."
|
@@ -210,13 +267,20 @@ module PactBroker
|
|
210
267
|
|
211
268
|
def publish_pacts pact_files
|
212
269
|
require 'pact_broker/client/publish_pacts'
|
270
|
+
|
213
271
|
write_options = options[:merge] ? { write: :merge } : {}
|
272
|
+
consumer_version_params = {
|
273
|
+
number: options.consumer_app_version,
|
274
|
+
branch: branch,
|
275
|
+
tags: tags,
|
276
|
+
build_url: options.build_url,
|
277
|
+
version_required: (!!options.branch || !!options.build_url || explict_auto_detect_version_properties)
|
278
|
+
}.compact
|
214
279
|
|
215
280
|
PactBroker::Client::PublishPacts.call(
|
216
281
|
options.broker_base_url,
|
217
282
|
file_list(pact_files),
|
218
|
-
|
219
|
-
tags,
|
283
|
+
consumer_version_params,
|
220
284
|
pact_broker_client_options.merge(write_options)
|
221
285
|
)
|
222
286
|
end
|
@@ -238,21 +302,35 @@ module PactBroker
|
|
238
302
|
require 'pact_broker/client/git'
|
239
303
|
|
240
304
|
t = [*options.tag]
|
241
|
-
t << PactBroker::Client::Git.branch if options.tag_with_git_branch
|
305
|
+
t << PactBroker::Client::Git.branch(raise_error: true) if options.tag_with_git_branch
|
242
306
|
t.compact.uniq
|
243
307
|
end
|
244
308
|
|
309
|
+
def branch
|
310
|
+
require 'pact_broker/client/git'
|
311
|
+
|
312
|
+
if options.branch.nil? && options.auto_detect_version_properties
|
313
|
+
PactBroker::Client::Git.branch(raise_error: explict_auto_detect_version_properties)
|
314
|
+
else
|
315
|
+
options.branch
|
316
|
+
end
|
317
|
+
end
|
318
|
+
|
319
|
+
def explict_auto_detect_version_properties
|
320
|
+
@explict_auto_detect_version_properties ||= ARGV.include?("--auto-detect-version-properties")
|
321
|
+
end
|
322
|
+
|
245
323
|
def pact_broker_client_options
|
246
324
|
client_options = { verbose: options.verbose }
|
247
|
-
client_options[:token] =
|
248
|
-
if options.broker_username
|
325
|
+
client_options[:token] = options.broker_token || ENV['PACT_BROKER_TOKEN']
|
326
|
+
if options.broker_username || ENV['PACT_BROKER_USERNAME']
|
249
327
|
client_options[:basic_auth] = {
|
250
|
-
username: options.broker_username,
|
251
|
-
password: options.broker_password
|
252
|
-
}
|
328
|
+
username: options.broker_username || ENV['PACT_BROKER_USERNAME'],
|
329
|
+
password: options.broker_password || ENV['PACT_BROKER_PASSWORD']
|
330
|
+
}.compact
|
253
331
|
end
|
254
332
|
|
255
|
-
client_options
|
333
|
+
client_options.compact
|
256
334
|
end
|
257
335
|
|
258
336
|
def parse_webhook_events
|