pact_broker-client 1.36.0 → 1.38.2
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 +32 -0
- data/Rakefile +2 -0
- data/bin/pact-broker +6 -0
- data/doc/pacts/markdown/Pact Broker Client - Pact Broker.md +180 -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 +85 -30
- 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 +3 -0
- data/lib/pact_broker/client/hal/entity.rb +44 -3
- data/lib/pact_broker/client/hal/http_client.rb +38 -2
- 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/text_formatter.rb +2 -0
- data/lib/pact_broker/client/publish_pacts.rb +2 -1
- data/lib/pact_broker/client/tasks/publication_task.rb +2 -0
- 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/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 +38 -4
- data/spec/lib/pact_broker/client/cli/broker_publish_spec.rb +1 -1
- data/spec/lib/pact_broker/client/cli/custom_thor_spec.rb +1 -7
- data/spec/lib/pact_broker/client/hal/entity_spec.rb +4 -3
- data/spec/lib/pact_broker/client/hal/http_client_spec.rb +64 -7
- 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 +181 -0
- data/spec/service_providers/record_deployment_spec.rb +219 -0
- data/spec/spec_helper.rb +2 -0
- metadata +17 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 134d7fe9f87596c2b56d1edfb136bdff06c045cf1f6e2ef8a3f93b805d3e108d
|
4
|
+
data.tar.gz: 57acfb55120c41e97ec1397dceebdd6f9784b9a3ff50c47c6464735c11c6e5a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 235afd0d61e101c549795f7dec7ea22f7d282456d59e72d8f49d7b383e358742e75f6eb866154f99af21b73a34671af6bfc6337fd72fc08b44049d47daeef2f9
|
7
|
+
data.tar.gz: 23e3aa5306ce014268b287d7de00b200476cea6f7711821ee5dac95586a3d8ccd1f9152959409209349b0a9a3cc77febcba26d6c90be7b7aa165ef2a3ceb3b22
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,35 @@
|
|
1
|
+
<a name="v1.38.2"></a>
|
2
|
+
### v1.38.2 (2021-04-01)
|
3
|
+
|
4
|
+
#### Features
|
5
|
+
|
6
|
+
* allow SSL verification to be disabled ([eb2125b](/../../commit/eb2125b))
|
7
|
+
* automatically retry at the http client level for 50x responses ([a7343f8](/../../commit/a7343f8))
|
8
|
+
|
9
|
+
<a name="v1.38.1"></a>
|
10
|
+
### v1.38.1 (2021-03-22)
|
11
|
+
|
12
|
+
<a name="v1.38.0"></a>
|
13
|
+
### v1.38.0 (2021-03-22)
|
14
|
+
|
15
|
+
<a name="v1.37.1"></a>
|
16
|
+
### v1.37.1 (2021-03-11)
|
17
|
+
|
18
|
+
#### Bug Fixes
|
19
|
+
|
20
|
+
* set username from PACT_BROKER_USERNAME environment variable correctly when -u specified for create-or-update-webhook and create-webhook ([2411396](/../../commit/2411396))
|
21
|
+
|
22
|
+
<a name="v1.37.0"></a>
|
23
|
+
### v1.37.0 (2021-03-01)
|
24
|
+
|
25
|
+
#### Features
|
26
|
+
|
27
|
+
* add record-deployment ([6e5e208](/../../commit/6e5e208))
|
28
|
+
|
29
|
+
#### Bug Fixes
|
30
|
+
|
31
|
+
* use refinement to add compact to Hash ([c2c1cab](/../../commit/c2c1cab))
|
32
|
+
|
1
33
|
<a name="v1.36.0"></a>
|
2
34
|
### v1.36.0 (2021-02-21)
|
3
35
|
|
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'] }
|
data/bin/pact-broker
CHANGED
@@ -1,4 +1,10 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
require 'pact_broker/client/cli/broker'
|
3
3
|
|
4
|
+
if ENV['PACT_BROKER_DISABLE_SSL_VERIFICATION'] == 'true' || ENV['PACT_DISABLE_SSL_VERIFICATION'] == 'true'
|
5
|
+
require 'openssl'
|
6
|
+
OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
|
7
|
+
$stderr.puts "WARN: SSL verification has been disabled by a dodgy hack (reassigning the VERIFY_PEER constant to VERIFY_NONE). You acknowledge that you do this at your own risk!"
|
8
|
+
end
|
9
|
+
|
4
10
|
PactBroker::Client::CLI::Broker.start
|
@@ -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,8 @@
|
|
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
|
+
|
31
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
|
32
42
|
|
33
43
|
* [A request for the index resource with the webhook relation](#a_request_for_the_index_resource_with_the_webhook_relation)
|
@@ -82,6 +92,8 @@
|
|
82
92
|
|
83
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
|
84
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
|
+
|
85
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
|
86
98
|
|
87
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
|
@@ -114,6 +126,87 @@
|
|
114
126
|
|
115
127
|
#### Interactions
|
116
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
|
+
```
|
117
210
|
<a name="a_request_for_the_compatibility_matrix_for_a_pacticipant_that_does_not_exist"></a>
|
118
211
|
Upon receiving **a request for the compatibility matrix for a pacticipant that does not exist** from Pact Broker Client, with
|
119
212
|
```json
|
@@ -535,6 +628,36 @@ Pact Broker will respond with:
|
|
535
628
|
}
|
536
629
|
}
|
537
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
|
+
```
|
538
661
|
<a name="a_request_for_the_index_resource"></a>
|
539
662
|
Upon receiving **a request for the index resource** from Pact Broker Client, with
|
540
663
|
```json
|
@@ -652,6 +775,36 @@ Pact Broker will respond with:
|
|
652
775
|
}
|
653
776
|
}
|
654
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
|
+
```
|
655
808
|
<a name="a_request_for_the_index_resource_given_the_pb:pacticipant-version_relation_exists_in_the_index_resource"></a>
|
656
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
|
657
810
|
```json
|
@@ -1775,6 +1928,33 @@ Pact Broker will respond with:
|
|
1775
1928
|
}
|
1776
1929
|
}
|
1777
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
|
+
```
|
1778
1958
|
<a name="a_request_to_register_the_repository_URL_of_a_pacticipant_given_the_'Pricing_Service'_already_exists_in_the_pact-broker"></a>
|
1779
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
|
1780
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
|
|
@@ -19,16 +22,12 @@ module PactBroker
|
|
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
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
|
22
|
-
method_option :broker_base_url, required: true, aliases: "-b", desc: "The base URL of the Pact Broker"
|
23
|
-
method_option :broker_username, aliases: "-u", desc: "Pact Broker basic auth username"
|
24
|
-
method_option :broker_password, aliases: "-p", desc: "Pact Broker basic auth password"
|
25
|
-
method_option :broker_token, aliases: "-k", desc: "Pact Broker bearer token"
|
26
25
|
method_option :output, aliases: "-o", desc: "json or table", default: 'table'
|
27
|
-
method_option :verbose, aliases: "-v", type: :boolean, default: false, required: false, desc: "Verbose output. Default: false"
|
28
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)"
|
29
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"
|
30
28
|
# Allow limit to be set manually until https://github.com/pact-foundation/pact_broker-client/issues/53 is fixed
|
31
29
|
method_option :limit, hide: true
|
30
|
+
shared_authentication_options
|
32
31
|
|
33
32
|
def can_i_deploy(*ignored_but_necessary)
|
34
33
|
require 'pact_broker/client/cli/version_selector_options_parser'
|
@@ -40,22 +39,19 @@ module PactBroker
|
|
40
39
|
can_i_deploy_options = { output: options.output, retry_while_unknown: options.retry_while_unknown, retry_interval: options.retry_interval }
|
41
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)
|
42
41
|
$stdout.puts result.message
|
43
|
-
|
42
|
+
$stdout.flush
|
43
|
+
exit(can_i_deploy_exit_status) unless result.success
|
44
44
|
end
|
45
45
|
|
46
46
|
desc 'publish PACT_DIRS_OR_FILES ...', "Publish pacts to a Pact Broker."
|
47
47
|
method_option :consumer_app_version, required: true, aliases: "-a", desc: "The consumer application version"
|
48
|
-
method_option :broker_base_url, required: true, aliases: "-b", desc: "The base URL of the Pact Broker"
|
49
|
-
method_option :broker_username, aliases: "-u", desc: "Pact Broker basic auth username"
|
50
|
-
method_option :broker_password, aliases: "-p", desc: "Pact Broker basic auth password"
|
51
|
-
method_option :broker_token, aliases: "-k", desc: "Pact Broker bearer token"
|
52
48
|
method_option :branch, aliases: "-h", desc: "Repository branch of the consumer version"
|
53
49
|
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."
|
54
50
|
method_option :tag, aliases: "-t", type: :array, banner: "TAG", desc: "Tag name for consumer version. Can be specified multiple times."
|
55
51
|
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"
|
56
52
|
method_option :build_url, desc: "The build URL that created the pact"
|
57
53
|
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."
|
58
|
-
|
54
|
+
shared_authentication_options
|
59
55
|
|
60
56
|
def publish(*pact_files)
|
61
57
|
require 'pact_broker/client/error'
|
@@ -73,11 +69,7 @@ module PactBroker
|
|
73
69
|
method_option :tag, aliases: "-t", type: :array, banner: "TAG", desc: "Tag name for pacticipant version. Can be specified multiple times."
|
74
70
|
method_option :auto_create_version, type: :boolean, default: false, desc: "Automatically create the pacticipant version if it does not exist. Default: false"
|
75
71
|
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"
|
76
|
-
|
77
|
-
method_option :broker_username, aliases: "-u", desc: "Pact Broker basic auth username"
|
78
|
-
method_option :broker_password, aliases: "-p", desc: "Pact Broker basic auth password"
|
79
|
-
method_option :broker_token, aliases: "-k", desc: "Pact Broker bearer token"
|
80
|
-
method_option :verbose, aliases: "-v", type: :boolean, default: false, required: false, desc: "Verbose output. Default: false"
|
72
|
+
shared_authentication_options
|
81
73
|
|
82
74
|
def create_version_tag
|
83
75
|
require 'pact_broker/client/create_tag'
|
@@ -97,12 +89,8 @@ module PactBroker
|
|
97
89
|
method_option :pacticipant, required: true, aliases: "-a", desc: "The name of the pacticipant that the version belongs to."
|
98
90
|
method_option :version, required: false, aliases: "-e", desc: "The pacticipant version number."
|
99
91
|
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."
|
100
|
-
method_option :broker_base_url, required: true, aliases: "-b", desc: "The base URL of the Pact Broker"
|
101
|
-
method_option :broker_username, aliases: "-u", desc: "Pact Broker basic auth username"
|
102
|
-
method_option :broker_password, aliases: "-p", desc: "Pact Broker basic auth password"
|
103
|
-
method_option :broker_token, aliases: "-k", desc: "Pact Broker bearer token"
|
104
92
|
method_option :output, aliases: "-o", desc: "json or table or id", default: 'table'
|
105
|
-
|
93
|
+
shared_authentication_options
|
106
94
|
|
107
95
|
desc 'describe-version', 'Describes a pacticipant version. If no version or tag is specified, the latest version is described.'
|
108
96
|
def describe_version
|
@@ -143,7 +131,7 @@ module PactBroker
|
|
143
131
|
|
144
132
|
desc 'test-webhook', 'Test the execution of a webhook'
|
145
133
|
method_option :uuid, type: :string, required: true, desc: "Specify the uuid for the webhook"
|
146
|
-
|
134
|
+
shared_authentication_options
|
147
135
|
def test_webhook
|
148
136
|
require 'pact_broker/client/webhooks/test'
|
149
137
|
result = PactBroker::Client::Webhooks::Test.call(options, pact_broker_client_options)
|
@@ -161,7 +149,7 @@ module PactBroker
|
|
161
149
|
desc 'create-or-update-pacticipant', 'Create or update pacticipant by name'
|
162
150
|
method_option :name, type: :string, required: true, desc: "Pacticipant name"
|
163
151
|
method_option :repository_url, type: :string, required: false, desc: "The repository URL of the pacticipant"
|
164
|
-
|
152
|
+
shared_authentication_options
|
165
153
|
verbose_option
|
166
154
|
def create_or_update_pacticipant(*required_but_ignored)
|
167
155
|
raise ::Thor::RequiredArgumentMissingError, "Pacticipant name cannot be blank" if options.name.strip.size == 0
|
@@ -172,7 +160,7 @@ module PactBroker
|
|
172
160
|
end
|
173
161
|
|
174
162
|
desc 'list-latest-pact-versions', 'List the latest pact for each integration'
|
175
|
-
|
163
|
+
shared_authentication_options
|
176
164
|
method_option :output, aliases: "-o", desc: "json or table", default: 'table'
|
177
165
|
def list_latest_pact_versions(*required_but_ignored)
|
178
166
|
require 'pact_broker/client/pacts/list_latest_versions'
|
@@ -181,6 +169,62 @@ module PactBroker
|
|
181
169
|
exit(1) unless result.success
|
182
170
|
end
|
183
171
|
|
172
|
+
if ENV.fetch("PACT_BROKER_FEATURES", "").include?("deployments")
|
173
|
+
|
174
|
+
ignored_and_hidden_potential_options_from_environment_variables
|
175
|
+
desc "record-deployment", "Record deployment of a pacticipant version to an environment"
|
176
|
+
method_option :pacticipant, required: true, aliases: "-a", desc: "The name of the pacticipant that was deployed."
|
177
|
+
method_option :version, required: true, aliases: "-e", desc: "The pacticipant version number that was deployed."
|
178
|
+
method_option :environment, required: true, desc: "The name of the environment that the pacticipant version was deployed to."
|
179
|
+
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."
|
180
|
+
method_option :output, aliases: "-o", desc: "json or text", default: 'text'
|
181
|
+
shared_authentication_options
|
182
|
+
|
183
|
+
def record_deployment
|
184
|
+
require 'pact_broker/client/versions/record_deployment'
|
185
|
+
params = {
|
186
|
+
pacticipant_name: options.pacticipant,
|
187
|
+
version_number: options.version,
|
188
|
+
environment_name: options.environment,
|
189
|
+
replaced_previous_deployed_version: options.replaced_previous_deployed_version,
|
190
|
+
output: options.output
|
191
|
+
}
|
192
|
+
result = PactBroker::Client::Versions::RecordDeployment.call(
|
193
|
+
params,
|
194
|
+
options.broker_base_url,
|
195
|
+
pact_broker_client_options
|
196
|
+
)
|
197
|
+
$stdout.puts result.message
|
198
|
+
exit(1) unless result.success
|
199
|
+
end
|
200
|
+
|
201
|
+
ignored_and_hidden_potential_options_from_environment_variables
|
202
|
+
desc "record-undeployment", "Record undeployment of (or the end of support for) a pacticipant version from an environment"
|
203
|
+
method_option :pacticipant, required: true, aliases: "-a", desc: "The name of the pacticipant that was deployed."
|
204
|
+
method_option :version, required: true, aliases: "-e", desc: "The pacticipant version number that was deployed."
|
205
|
+
method_option :environment, required: true, desc: "The name of the environment that the pacticipant version was deployed to."
|
206
|
+
method_option :output, aliases: "-o", desc: "json or text", default: 'text'
|
207
|
+
shared_authentication_options
|
208
|
+
|
209
|
+
def record_undeployment
|
210
|
+
require 'pact_broker/client/versions/record_undeployment'
|
211
|
+
params = {
|
212
|
+
pacticipant_name: options.pacticipant,
|
213
|
+
version_number: options.version,
|
214
|
+
environment_name: options.environment,
|
215
|
+
output: options.output
|
216
|
+
}
|
217
|
+
result = PactBroker::Client::Versions::RecordUndeployment.call(
|
218
|
+
params,
|
219
|
+
options.broker_base_url,
|
220
|
+
pact_broker_client_options
|
221
|
+
)
|
222
|
+
$stdout.puts result.message
|
223
|
+
exit(1) unless result.success
|
224
|
+
end
|
225
|
+
|
226
|
+
end
|
227
|
+
|
184
228
|
ignored_and_hidden_potential_options_from_environment_variables
|
185
229
|
desc 'version', "Show the pact_broker-client gem version"
|
186
230
|
def version
|
@@ -195,6 +239,16 @@ module PactBroker
|
|
195
239
|
true
|
196
240
|
end
|
197
241
|
|
242
|
+
def can_i_deploy_exit_status
|
243
|
+
exit_code_string = ENV.fetch('PACT_BROKER_CAN_I_DEPLOY_EXIT_CODE_BETA', '')
|
244
|
+
if exit_code_string =~ /^\d+$/
|
245
|
+
$stderr.puts "Exiting can-i-deploy with configured exit code #{exit_code_string}"
|
246
|
+
exit_code_string.to_i
|
247
|
+
else
|
248
|
+
1
|
249
|
+
end
|
250
|
+
end
|
251
|
+
|
198
252
|
def validate_credentials
|
199
253
|
if options.broker_username && options.broker_token
|
200
254
|
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."
|
@@ -214,6 +268,7 @@ module PactBroker
|
|
214
268
|
|
215
269
|
def publish_pacts pact_files
|
216
270
|
require 'pact_broker/client/publish_pacts'
|
271
|
+
|
217
272
|
write_options = options[:merge] ? { write: :merge } : {}
|
218
273
|
consumer_version_params = {
|
219
274
|
number: options.consumer_app_version,
|
@@ -268,15 +323,15 @@ module PactBroker
|
|
268
323
|
|
269
324
|
def pact_broker_client_options
|
270
325
|
client_options = { verbose: options.verbose }
|
271
|
-
client_options[:token] =
|
272
|
-
if options.broker_username
|
326
|
+
client_options[:token] = options.broker_token || ENV['PACT_BROKER_TOKEN']
|
327
|
+
if options.broker_username || ENV['PACT_BROKER_USERNAME']
|
273
328
|
client_options[:basic_auth] = {
|
274
|
-
username: options.broker_username,
|
275
|
-
password: options.broker_password
|
276
|
-
}
|
329
|
+
username: options.broker_username || ENV['PACT_BROKER_USERNAME'],
|
330
|
+
password: options.broker_password || ENV['PACT_BROKER_PASSWORD']
|
331
|
+
}.compact
|
277
332
|
end
|
278
333
|
|
279
|
-
client_options
|
334
|
+
client_options.compact
|
280
335
|
end
|
281
336
|
|
282
337
|
def parse_webhook_events
|