pact_broker-client 1.42.0 → 1.43.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1da6a5e8cef3f91ae1cd441eb92dd2d788ad67ccac947c476090787b27b134ea
4
- data.tar.gz: 0df7d512c7c45a8b7ea4d049560be927d1d7c3273c0ec157c22cb81651caa16e
3
+ metadata.gz: 62d6345d206920c405cd04c6a3984ac2d3de6ebc687283eb22f3400f7e51e7fa
4
+ data.tar.gz: 18e2425b5fb80db316beaf58977432316afe9a48cc508a619006c5e8a9ec59af
5
5
  SHA512:
6
- metadata.gz: 27dc97ff230f86c530b8aed93cf5e86334dd51982017627a7c99de57a2cf8f65af6706c5a73c5d1999df0b145b60b88a649b716fc7f859cbc289193f9dbca437
7
- data.tar.gz: 1f970d5b863efc1bc27c55515b95afe8c4a3e166e3da62819ac92e1d4f6205fccb7f8979925266dc37342c1be496310c59a150408398e000b5e8e8b2079ab609
6
+ metadata.gz: 6ec0cca0de9787d4493143c2a2d9f9512df1b800c978a274a58b0b14a9d8fd7fc6c87609d2c3dd7f6916273c6600b9ec11a98dc47b8ac614aa71843f97c48378
7
+ data.tar.gz: f0c96d94f6bcd765ac5ac20bbc4950f64b205555461bdc2ca0a7fcfbe5d57e704eea430a3ddf1b11e2b499a76d828a2fdb552b8ce5a03d56bb3b852378690a32
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
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
+
1
8
  <a name="v1.42.0"></a>
2
9
  ### v1.42.0 (2021-05-31)
3
10
 
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 # The pacticipant name. Use once for each pacticipant being checked.
82
- -e, [--version=VERSION] # The pacticipant version. Must be entered after the --pacticipant that it relates to.
83
- -l, [--latest=[TAG]] # Use the latest pacticipant version. Optionally specify a TAG to use the latest version with the specified tag.
84
- [--to=TAG] # This is too hard to explain in a short sentence. Look at the examples.
85
- -b, --broker-base-url=BROKER_BASE_URL # The base URL of the Pact Broker
86
- -u, [--broker-username=BROKER_USERNAME] # Pact Broker basic auth username
87
- -p, [--broker-password=BROKER_PASSWORD] # Pact Broker basic auth password
88
- -k, [--broker-token=BROKER_TOKEN] # Pact Broker bearer token
89
- -o, [--output=OUTPUT] # json or table
90
- # Default: table
91
- -v, [--verbose], [--no-verbose] # Verbose output. Default: false
92
- [--retry-while-unknown=TIMES] # The number of times to retry while there is an unknown verification result (ie. the provider verification is likely still running)
93
- # Default: 0
94
- [--retry-interval=SECONDS] # The time between retries in seconds. Use in conjuction with --retry-while-unknown
95
- # Default: 10
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 compatible. Prints out the relevant
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, PACT_BROKER_BASE_URL_USERNAME and PACT_BROKER_BASE_URL_PASSWORD may be used
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
 
@@ -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&#39;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](#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
@@ -66,6 +76,8 @@
66
76
 
67
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_&#39;Pricing_Service&#39;_and_&#39;Condor&#39;_already_exist_in_the_pact-broker) given the 'Pricing Service' and 'Condor' already exist in the pact-broker
68
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
+
69
81
  * [A request to get the Pricing Service](#a_request_to_get_the_Pricing_Service_given_the_&#39;Pricing_Service&#39;_already_exists_in_the_pact-broker) given the 'Pricing Service' already exists in the pact-broker
70
82
 
71
83
  * [A request to get the Pricing Service](#a_request_to_get_the_Pricing_Service_given_the_&#39;Pricing_Service&#39;_does_not_exist_in_the_pact-broker) given the 'Pricing Service' does not exist in the pact-broker
@@ -86,6 +98,8 @@
86
98
 
87
99
  * [A request to publish contracts](#a_request_to_publish_contracts)
88
100
 
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
102
+
89
103
  * [A request to register the repository URL of a pacticipant](#a_request_to_register_the_repository_URL_of_a_pacticipant_given_the_&#39;Pricing_Service&#39;_already_exists_in_the_pact-broker) given the 'Pricing Service' already exists in the pact-broker
90
104
 
91
105
  * [A request to register the repository URL of a pacticipant](#a_request_to_register_the_repository_URL_of_a_pacticipant_given_the_&#39;Pricing_Service&#39;_does_not_exist_in_the_pact-broker) given the 'Pricing Service' does not exist in the pact-broker
@@ -118,6 +132,87 @@
118
132
 
119
133
  #### Interactions
120
134
 
135
+ <a name="a_request_for_a_pacticipant_version_given_version_5556b8149bf8bac76bc30f50a8a2dd4c22c85f30_of_pacticipant_Foo_exists_with_2_environments_that_aren&#39;t_test_available_for_deployment"></a>
136
+ 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
137
+ ```json
138
+ {
139
+ "method": "GET",
140
+ "path": "/HAL-REL-PLACEHOLDER-PB-PACTICIPANT-VERSION-Foo-5556b8149bf8bac76bc30f50a8a2dd4c22c85f30",
141
+ "headers": {
142
+ "Accept": "application/hal+json"
143
+ }
144
+ }
145
+ ```
146
+ Pact Broker will respond with:
147
+ ```json
148
+ {
149
+ "status": 200,
150
+ "headers": {
151
+ "Content-Type": "application/hal+json;charset=utf-8"
152
+ },
153
+ "body": {
154
+ "_links": {
155
+ "pb:record-deployment": [
156
+ {
157
+ "name": "prod",
158
+ "href": "href"
159
+ },
160
+ {
161
+ "name": "dev",
162
+ "href": "href"
163
+ }
164
+ ]
165
+ }
166
+ }
167
+ }
168
+ ```
169
+ <a name="a_request_for_a_pacticipant_version_given_version_5556b8149bf8bac76bc30f50a8a2dd4c22c85f30_of_pacticipant_Foo_exists_with_a_test_environment_available_for_deployment"></a>
170
+ 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
171
+ ```json
172
+ {
173
+ "method": "GET",
174
+ "path": "/HAL-REL-PLACEHOLDER-PB-PACTICIPANT-VERSION-Foo-5556b8149bf8bac76bc30f50a8a2dd4c22c85f30",
175
+ "headers": {
176
+ "Accept": "application/hal+json"
177
+ }
178
+ }
179
+ ```
180
+ Pact Broker will respond with:
181
+ ```json
182
+ {
183
+ "status": 200,
184
+ "headers": {
185
+ "Content-Type": "application/hal+json;charset=utf-8"
186
+ },
187
+ "body": {
188
+ "_links": {
189
+ "pb:record-deployment": [
190
+ {
191
+ "name": "test",
192
+ "href": "http://localhost:1234/HAL-REL-PLACEHOLDER-PB-RECORD-DEPLOYMENT-FOO-5556B8149BF8BAC76BC30F50A8A2DD4C22C85F30-TEST"
193
+ }
194
+ ]
195
+ }
196
+ }
197
+ }
198
+ ```
199
+ <a name="a_request_for_a_pacticipant_version_given_version_5556b8149bf8bac76bc30f50a8a2dd4c22c85f30_of_pacticipant_Foo_does_not_exist"></a>
200
+ Given **version 5556b8149bf8bac76bc30f50a8a2dd4c22c85f30 of pacticipant Foo does not exist**, upon receiving **a request for a pacticipant version** from Pact Broker Client, with
201
+ ```json
202
+ {
203
+ "method": "GET",
204
+ "path": "/HAL-REL-PLACEHOLDER-PB-PACTICIPANT-VERSION-Foo-5556b8149bf8bac76bc30f50a8a2dd4c22c85f30",
205
+ "headers": {
206
+ "Accept": "application/hal+json"
207
+ }
208
+ }
209
+ ```
210
+ Pact Broker will respond with:
211
+ ```json
212
+ {
213
+ "status": 404
214
+ }
215
+ ```
121
216
  <a name="a_request_for_the_compatibility_matrix_for_a_pacticipant_that_does_not_exist"></a>
122
217
  Upon receiving **a request for the compatibility matrix for a pacticipant that does not exist** from Pact Broker Client, with
123
218
  ```json
@@ -539,6 +634,36 @@ Pact Broker will respond with:
539
634
  }
540
635
  }
541
636
  ```
637
+ <a name="a_request_for_the_environments_given_an_environment_with_name_test_exists"></a>
638
+ Given **an environment with name test exists**, upon receiving **a request for the environments** from Pact Broker Client, with
639
+ ```json
640
+ {
641
+ "method": "GET",
642
+ "path": "/HAL-REL-PLACEHOLDER-PB-ENVIRONMENTS",
643
+ "headers": {
644
+ "Accept": "application/hal+json"
645
+ }
646
+ }
647
+ ```
648
+ Pact Broker will respond with:
649
+ ```json
650
+ {
651
+ "status": 200,
652
+ "headers": {
653
+ "Content-Type": "application/hal+json;charset=utf-8"
654
+ },
655
+ "body": {
656
+ "_links": {
657
+ "pb:environments": [
658
+ {
659
+ "name": "test",
660
+ "href": "href"
661
+ }
662
+ ]
663
+ }
664
+ }
665
+ }
666
+ ```
542
667
  <a name="a_request_for_the_index_resource"></a>
543
668
  Upon receiving **a request for the index resource** from Pact Broker Client, with
544
669
  ```json
@@ -656,6 +781,36 @@ Pact Broker will respond with:
656
781
  }
657
782
  }
658
783
  ```
784
+ <a name="a_request_for_the_index_resource_given_the_pb:pacticipant-version_and_pb:environments_relations_exist_in_the_index_resource"></a>
785
+ 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
786
+ ```json
787
+ {
788
+ "method": "GET",
789
+ "path": "/",
790
+ "headers": {
791
+ "Accept": "application/hal+json"
792
+ }
793
+ }
794
+ ```
795
+ Pact Broker will respond with:
796
+ ```json
797
+ {
798
+ "status": 200,
799
+ "headers": {
800
+ "Content-Type": "application/hal+json;charset=utf-8"
801
+ },
802
+ "body": {
803
+ "_links": {
804
+ "pb:pacticipant-version": {
805
+ "href": "http://localhost:1234/HAL-REL-PLACEHOLDER-PB-PACTICIPANT-VERSION-{pacticipant}-{version}"
806
+ },
807
+ "pb:environments": {
808
+ "href": "http://localhost:1234/HAL-REL-PLACEHOLDER-PB-ENVIRONMENTS"
809
+ }
810
+ }
811
+ }
812
+ }
813
+ ```
659
814
  <a name="a_request_for_the_index_resource_given_the_pb:pacticipant-version_relation_exists_in_the_index_resource"></a>
660
815
  Given **the pb:pacticipant-version relation exists in the index resource**, upon receiving **a request for the index resource** from Pact Broker Client, with
661
816
  ```json
@@ -1454,6 +1609,83 @@ Pact Broker will respond with:
1454
1609
  }
1455
1610
  }
1456
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
+ ```
1457
1689
  <a name="a_request_to_get_the_Pricing_Service_given_the_&#39;Pricing_Service&#39;_already_exists_in_the_pact-broker"></a>
1458
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
1459
1691
  ```json
@@ -1876,6 +2108,33 @@ Pact Broker will respond with:
1876
2108
  }
1877
2109
  }
1878
2110
  ```
2111
+ <a name="a_request_to_record_a_deployment_given_version_5556b8149bf8bac76bc30f50a8a2dd4c22c85f30_of_pacticipant_Foo_exists_with_a_test_environment_available_for_deployment"></a>
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
2113
+ ```json
2114
+ {
2115
+ "method": "POST",
2116
+ "path": "/HAL-REL-PLACEHOLDER-PB-RECORD-DEPLOYMENT-FOO-5556B8149BF8BAC76BC30F50A8A2DD4C22C85F30-TEST",
2117
+ "headers": {
2118
+ "Content-Type": "application/json",
2119
+ "Accept": "application/hal+json"
2120
+ },
2121
+ "body": {
2122
+ "target": "blue"
2123
+ }
2124
+ }
2125
+ ```
2126
+ Pact Broker will respond with:
2127
+ ```json
2128
+ {
2129
+ "status": 201,
2130
+ "headers": {
2131
+ "Content-Type": "application/hal+json;charset=utf-8"
2132
+ },
2133
+ "body": {
2134
+ "target": "blue"
2135
+ }
2136
+ }
2137
+ ```
1879
2138
  <a name="a_request_to_register_the_repository_URL_of_a_pacticipant_given_the_&#39;Pricing_Service&#39;_already_exists_in_the_pact-broker"></a>
1880
2139
  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
1881
2140
  ```json
@@ -25,10 +25,7 @@ module PactBroker
25
25
 
26
26
  method_option :pacticipant, required: true, aliases: "-a", desc: "The pacticipant name. Use once for each pacticipant being checked."
27
27
  method_option :version, required: false, aliases: "-e", desc: "The pacticipant version. Must be entered after the --pacticipant that it relates to."
28
-
29
- if ENV.fetch("PACT_BROKER_FEATURES", "").include?("ignore")
30
- method_option :ignore, required: false, desc: "The pacticipant name to ignore. Use once for each pacticipant being ignored. A specific version can be ignored by also specifying a --version."
31
- end
28
+ method_option :ignore, required: false, desc: "The pacticipant name to ignore. Use once for each pacticipant being ignored. A specific version can be ignored by also specifying a --version after the pacticipant name option."
32
29
  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."
33
30
  method_option :to, required: false, banner: 'TAG', desc: "This is too hard to explain in a short sentence. Look at the examples.", default: nil
34
31
  method_option :to_environment, required: false, banner: 'ENVIRONMENT', desc: "The environment into which the pacticipant(s) are to be deployed", default: nil, hide: true
@@ -1,5 +1,5 @@
1
1
  module PactBroker
2
2
  module Client
3
- VERSION = '1.42.0'
3
+ VERSION = '1.43.0'
4
4
  end
5
5
  end
@@ -1,41 +1,27 @@
1
- require 'pact_broker/client/hal_client_methods'
2
- require 'pact_broker/client/error'
3
- require 'pact_broker/client/command_result'
1
+ require 'pact_broker/client/base_command'
4
2
 
5
3
  module PactBroker
6
4
  module Client
7
5
  class Versions
8
- class RecordDeployment
9
- include PactBroker::Client::HalClientMethods
6
+ class RecordDeployment < PactBroker::Client::BaseCommand
10
7
 
11
8
  NOT_SUPPORTED_MESSAGE = "This version of the Pact Broker does not support recording deployments. Please upgrade to version 2.80.0 or later."
12
9
 
13
- def self.call(params, pact_broker_base_url, pact_broker_client_options)
14
- new(params, pact_broker_base_url, pact_broker_client_options).call
15
- end
16
-
17
- def initialize(params, pact_broker_base_url, pact_broker_client_options)
18
- @pact_broker_base_url = pact_broker_base_url
10
+ def initialize(params, options, pact_broker_client_options)
11
+ super
19
12
  @pacticipant_name = params.fetch(:pacticipant_name)
20
13
  @version_number = params.fetch(:version_number)
21
14
  @environment_name = params.fetch(:environment_name)
22
15
  @target = params.fetch(:target)
23
- @output = params.fetch(:output)
24
- @pact_broker_client_options = pact_broker_client_options
25
16
  end
26
17
 
27
- def call
28
- check_if_command_supported
29
- record_deployment
18
+ private
30
19
 
20
+ def do_call
21
+ record_deployment
31
22
  PactBroker::Client::CommandResult.new(true, result_message)
32
- rescue PactBroker::Client::Error => e
33
- PactBroker::Client::CommandResult.new(false, e.message)
34
23
  end
35
24
 
36
- private
37
-
38
- attr_reader :pact_broker_base_url, :pact_broker_client_options
39
25
  attr_reader :pacticipant_name, :version_number, :environment_name, :target, :output
40
26
  attr_reader :deployed_version_resource
41
27
 
@@ -79,25 +65,15 @@ module PactBroker
79
65
  end
80
66
 
81
67
  def result_message
82
- if output == "text"
83
- message = "Recorded deployment of #{pacticipant_name} version #{version_number} to #{environment_name}"
84
- message = "#{message} (target #{target})" if target
85
- "#{message} in #{pact_broker_name}."
86
- elsif output == "json"
68
+ if json_output?
87
69
  deployed_version_resource.response.raw_body
88
70
  else
89
- ""
71
+ message = "Recorded deployment of #{pacticipant_name} version #{version_number} to #{environment_name} environment"
72
+ message = "#{message} (target #{target})" if target
73
+ green("#{message} in #{pact_broker_name}.")
90
74
  end
91
75
  end
92
76
 
93
- def pact_broker_name
94
- is_pactflow? ? "Pactflow" : "the Pact Broker"
95
- end
96
-
97
- def is_pactflow?
98
- deployed_version_resource.response.headers.keys.any?{ | header_name | header_name.downcase.include?("pactflow") }
99
- end
100
-
101
77
  def check_if_command_supported
102
78
  unless index_resource.can?("pb:environments")
103
79
  raise PactBroker::Client::Error.new(NOT_SUPPORTED_MESSAGE)
@@ -22,14 +22,18 @@ module PactBroker
22
22
  pacticipant_name: "Foo",
23
23
  version_number: "1",
24
24
  environment_name: "test",
25
- target: target,
26
- output: "text"
25
+ target: target
27
26
  }
28
27
  end
29
28
 
30
- let(:pact_broker_client_options) { {} }
29
+ let(:options) do
30
+ {
31
+ output: "text"
32
+ }
33
+ end
34
+ let(:pact_broker_client_options) { { pact_broker_base_url: broker_base_url} }
31
35
 
32
- subject { RecordDeployment.call(params, broker_base_url, pact_broker_client_options) }
36
+ subject { RecordDeployment.call(params, options, pact_broker_client_options) }
33
37
 
34
38
  context "when the pb:environments relation does not exist" do
35
39
  it "returns an error response" do
@@ -43,36 +47,25 @@ module PactBroker
43
47
  allow_any_instance_of(RecordDeployment).to receive(:check_if_command_supported)
44
48
  allow_any_instance_of(RecordDeployment).to receive(:check_environment_exists)
45
49
  allow_any_instance_of(RecordDeployment).to receive(:record_deployment)
46
- allow_any_instance_of(RecordDeployment).to receive(:deployed_version_resource).and_return(deployed_version_resource)
50
+ allow_any_instance_of(RecordDeployment).to receive(:index_resource).and_return(index_resource)
47
51
  end
48
52
 
49
53
  let(:response_headers) { { "X-Pactflow-Sha" => "abc" } }
50
54
 
51
- let(:deployed_version_resource) do
55
+ let(:index_resource) do
52
56
  double('PactBroker::Client::Hal::Entity', response: double('response', headers: response_headers) )
53
57
  end
54
58
 
55
59
  it "indicates the API was Pactflow" do
56
- expect(subject.message).to include "Recorded deployment of Foo version 1 to test (target blue) in Pactflow"
60
+ expect(subject.message).to include "Recorded deployment of Foo version 1 to test environment (target blue) in Pactflow"
57
61
  end
58
- end
59
62
 
60
- context "when target is false" do
61
- before do
62
- allow_any_instance_of(RecordDeployment).to receive(:check_if_command_supported)
63
- allow_any_instance_of(RecordDeployment).to receive(:check_environment_exists)
64
- allow_any_instance_of(RecordDeployment).to receive(:record_deployment)
65
- allow_any_instance_of(RecordDeployment).to receive(:pact_broker_name).and_return("")
66
- end
67
-
68
- let(:target) { false }
69
-
70
- let(:deployed_version_resource) do
71
- double('PactBroker::Client::Hal::Entity', response: double('response', headers: response_headers) )
72
- end
63
+ context "when target is nil" do
64
+ let(:target) { nil }
73
65
 
74
- it "does not include the message about marking the previous version as undeployed" do
75
- expect(subject.message).to_not include "undeployed"
66
+ it "does not include the target in the result message" do
67
+ expect(subject.message).to include "Recorded deployment of Foo version 1 to test environment in"
68
+ end
76
69
  end
77
70
  end
78
71
  end
@@ -292,6 +292,94 @@
292
292
  }
293
293
  }
294
294
  },
295
+ {
296
+ "description": "a request to determine if Bar can be deployed with all Foo tagged prod, ignoring the verification for Foo version 3.4.5",
297
+ "providerState": "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",
298
+ "request": {
299
+ "method": "get",
300
+ "path": "/matrix",
301
+ "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"
302
+ },
303
+ "response": {
304
+ "status": 200,
305
+ "headers": {
306
+ "Content-Type": "application/hal+json;charset=utf-8"
307
+ },
308
+ "body": {
309
+ "summary": {
310
+ "deployable": true,
311
+ "ignored": 1
312
+ },
313
+ "notices": [
314
+ {
315
+ "text": "some notice",
316
+ "type": "info"
317
+ }
318
+ ],
319
+ "matrix": [
320
+ {
321
+ "consumer": {
322
+ "name": "Foo",
323
+ "version": {
324
+ "number": "1.2.3"
325
+ }
326
+ },
327
+ "provider": {
328
+ "name": "Bar",
329
+ "version": {
330
+ "number": "4.5.6"
331
+ }
332
+ },
333
+ "verificationResult": {
334
+ "success": true,
335
+ "_links": {
336
+ "self": {
337
+ "href": "http://result"
338
+ }
339
+ }
340
+ }
341
+ },
342
+ {
343
+ "consumer": {
344
+ "name": "Foo",
345
+ "version": {
346
+ "number": "3.4.5"
347
+ }
348
+ },
349
+ "provider": {
350
+ "name": "Bar",
351
+ "version": {
352
+ "number": "4.5.6"
353
+ }
354
+ },
355
+ "verificationResult": {
356
+ "success": false,
357
+ "_links": {
358
+ "self": {
359
+ "href": "http://result"
360
+ }
361
+ }
362
+ },
363
+ "ignored": true
364
+ }
365
+ ]
366
+ },
367
+ "matchingRules": {
368
+ "$.body.notices": {
369
+ "min": 1
370
+ },
371
+ "$.body.notices[*].*": {
372
+ "match": "type"
373
+ },
374
+ "$.body.matrix[0].verificationResult._links.self.href": {
375
+ "match": "type"
376
+ },
377
+ "$.body.matrix[1].verificationResult._links.self.href": {
378
+ "match": "type"
379
+ }
380
+ }
381
+ }
382
+ },
295
383
  {
296
384
  "description": "a request for the compatibility matrix for Foo version 1.2.3 and Bar version 4.5.6",
297
385
  "providerState": "the pact for Foo version 1.2.3 has been verified by Bar version 4.5.6",
@@ -1657,6 +1745,187 @@
1657
1745
  }
1658
1746
  }
1659
1747
  },
1748
+ {
1749
+ "description": "a request for the index resource",
1750
+ "providerState": "the pb:pacticipant-version and pb:environments relations exist in the index resource",
1751
+ "request": {
1752
+ "method": "GET",
1753
+ "path": "/",
1754
+ "headers": {
1755
+ "Accept": "application/hal+json"
1756
+ }
1757
+ },
1758
+ "response": {
1759
+ "status": 200,
1760
+ "headers": {
1761
+ "Content-Type": "application/hal+json;charset=utf-8"
1762
+ },
1763
+ "body": {
1764
+ "_links": {
1765
+ "pb:pacticipant-version": {
1766
+ "href": "http://localhost:1234/HAL-REL-PLACEHOLDER-PB-PACTICIPANT-VERSION-{pacticipant}-{version}"
1767
+ },
1768
+ "pb:environments": {
1769
+ "href": "http://localhost:1234/HAL-REL-PLACEHOLDER-PB-ENVIRONMENTS"
1770
+ }
1771
+ }
1772
+ },
1773
+ "matchingRules": {
1774
+ "$.body._links.pb:pacticipant-version.href": {
1775
+ "match": "regex",
1776
+ "regex": "http:\\/\\/.*{pacticipant}.*{version}"
1777
+ },
1778
+ "$.body._links.pb:environments.href": {
1779
+ "match": "regex",
1780
+ "regex": "http:\\/\\/.*"
1781
+ }
1782
+ }
1783
+ }
1784
+ },
1785
+ {
1786
+ "description": "a request for a pacticipant version",
1787
+ "providerState": "version 5556b8149bf8bac76bc30f50a8a2dd4c22c85f30 of pacticipant Foo exists with a test environment available for deployment",
1788
+ "request": {
1789
+ "method": "GET",
1790
+ "path": "/HAL-REL-PLACEHOLDER-PB-PACTICIPANT-VERSION-Foo-5556b8149bf8bac76bc30f50a8a2dd4c22c85f30",
1791
+ "headers": {
1792
+ "Accept": "application/hal+json"
1793
+ }
1794
+ },
1795
+ "response": {
1796
+ "status": 200,
1797
+ "headers": {
1798
+ "Content-Type": "application/hal+json;charset=utf-8"
1799
+ },
1800
+ "body": {
1801
+ "_links": {
1802
+ "pb:record-deployment": [
1803
+ {
1804
+ "name": "test",
1805
+ "href": "http://localhost:1234/HAL-REL-PLACEHOLDER-PB-RECORD-DEPLOYMENT-FOO-5556B8149BF8BAC76BC30F50A8A2DD4C22C85F30-TEST"
1806
+ }
1807
+ ]
1808
+ }
1809
+ },
1810
+ "matchingRules": {
1811
+ "$.body._links.pb:record-deployment[0].href": {
1812
+ "match": "regex",
1813
+ "regex": "http:\\/\\/.*"
1814
+ }
1815
+ }
1816
+ }
1817
+ },
1818
+ {
1819
+ "description": "a request to record a deployment",
1820
+ "providerState": "version 5556b8149bf8bac76bc30f50a8a2dd4c22c85f30 of pacticipant Foo exists with a test environment available for deployment",
1821
+ "request": {
1822
+ "method": "POST",
1823
+ "path": "/HAL-REL-PLACEHOLDER-PB-RECORD-DEPLOYMENT-FOO-5556B8149BF8BAC76BC30F50A8A2DD4C22C85F30-TEST",
1824
+ "headers": {
1825
+ "Content-Type": "application/json",
1826
+ "Accept": "application/hal+json"
1827
+ },
1828
+ "body": {
1829
+ "target": "blue"
1830
+ }
1831
+ },
1832
+ "response": {
1833
+ "status": 201,
1834
+ "headers": {
1835
+ "Content-Type": "application/hal+json;charset=utf-8"
1836
+ },
1837
+ "body": {
1838
+ "target": "blue"
1839
+ }
1840
+ }
1841
+ },
1842
+ {
1843
+ "description": "a request for a pacticipant version",
1844
+ "providerState": "version 5556b8149bf8bac76bc30f50a8a2dd4c22c85f30 of pacticipant Foo does not exist",
1845
+ "request": {
1846
+ "method": "GET",
1847
+ "path": "/HAL-REL-PLACEHOLDER-PB-PACTICIPANT-VERSION-Foo-5556b8149bf8bac76bc30f50a8a2dd4c22c85f30",
1848
+ "headers": {
1849
+ "Accept": "application/hal+json"
1850
+ }
1851
+ },
1852
+ "response": {
1853
+ "status": 404,
1854
+ "headers": {
1855
+ }
1856
+ }
1857
+ },
1858
+ {
1859
+ "description": "a request for a pacticipant version",
1860
+ "providerState": "version 5556b8149bf8bac76bc30f50a8a2dd4c22c85f30 of pacticipant Foo exists with 2 environments that aren't test available for deployment",
1861
+ "request": {
1862
+ "method": "GET",
1863
+ "path": "/HAL-REL-PLACEHOLDER-PB-PACTICIPANT-VERSION-Foo-5556b8149bf8bac76bc30f50a8a2dd4c22c85f30",
1864
+ "headers": {
1865
+ "Accept": "application/hal+json"
1866
+ }
1867
+ },
1868
+ "response": {
1869
+ "status": 200,
1870
+ "headers": {
1871
+ "Content-Type": "application/hal+json;charset=utf-8"
1872
+ },
1873
+ "body": {
1874
+ "_links": {
1875
+ "pb:record-deployment": [
1876
+ {
1877
+ "name": "prod",
1878
+ "href": "href"
1879
+ },
1880
+ {
1881
+ "name": "dev",
1882
+ "href": "href"
1883
+ }
1884
+ ]
1885
+ }
1886
+ },
1887
+ "matchingRules": {
1888
+ "$.body._links.pb:record-deployment[0]": {
1889
+ "match": "type"
1890
+ },
1891
+ "$.body._links.pb:record-deployment[1]": {
1892
+ "match": "type"
1893
+ }
1894
+ }
1895
+ }
1896
+ },
1897
+ {
1898
+ "description": "a request for the environments",
1899
+ "providerState": "an environment with name test exists",
1900
+ "request": {
1901
+ "method": "GET",
1902
+ "path": "/HAL-REL-PLACEHOLDER-PB-ENVIRONMENTS",
1903
+ "headers": {
1904
+ "Accept": "application/hal+json"
1905
+ }
1906
+ },
1907
+ "response": {
1908
+ "status": 200,
1909
+ "headers": {
1910
+ "Content-Type": "application/hal+json;charset=utf-8"
1911
+ },
1912
+ "body": {
1913
+ "_links": {
1914
+ "pb:environments": [
1915
+ {
1916
+ "name": "test",
1917
+ "href": "href"
1918
+ }
1919
+ ]
1920
+ }
1921
+ },
1922
+ "matchingRules": {
1923
+ "$.body._links.pb:environments[0].href": {
1924
+ "match": "type"
1925
+ }
1926
+ }
1927
+ }
1928
+ },
1660
1929
  {
1661
1930
  "description": "a request to create a webhook with a JSON body for a consumer and provider",
1662
1931
  "providerState": "the 'Pricing Service' and 'Condor' already exist in the pact-broker",
@@ -2,7 +2,7 @@ require_relative 'pact_helper'
2
2
  require 'pact_broker/client/can_i_deploy'
3
3
 
4
4
  module PactBroker::Client
5
- describe Matrix, :pact => true, skip: true do
5
+ describe Matrix, :pact => true do
6
6
 
7
7
  include_context "pact broker"
8
8
 
@@ -1,7 +1,7 @@
1
1
  require 'service_providers/pact_helper'
2
2
  require 'pact_broker/client/versions/record_deployment'
3
3
 
4
- RSpec.describe "recording a deployment", pact: true, skip: true do
4
+ RSpec.describe "recording a deployment", pact: true do
5
5
  include_context "pact broker"
6
6
  include PactBrokerPactHelperMethods
7
7
 
@@ -15,13 +15,17 @@ RSpec.describe "recording a deployment", pact: true, skip: true do
15
15
  pacticipant_name: pacticipant_name,
16
16
  version_number: version_number,
17
17
  environment_name: environment_name,
18
- target: target,
18
+ target: target
19
+ }
20
+ end
21
+ let(:options) do
22
+ {
19
23
  output: output
20
24
  }
21
25
  end
22
- let(:pact_broker_client_options) { {} }
26
+ let(:pact_broker_client_options) { { pact_broker_base_url: broker_base_url } }
23
27
 
24
- subject { PactBroker::Client::Versions::RecordDeployment.call(params, broker_base_url, pact_broker_client_options) }
28
+ subject { PactBroker::Client::Versions::RecordDeployment.call(params, options, pact_broker_client_options) }
25
29
 
26
30
  def mock_index
27
31
  pact_broker
@@ -168,7 +172,7 @@ RSpec.describe "recording a deployment", pact: true, skip: true do
168
172
 
169
173
  it "returns a success message" do
170
174
  expect(subject.success).to be true
171
- expect(subject.message).to eq "Recorded deployment of Foo version 5556b8149bf8bac76bc30f50a8a2dd4c22c85f30 to test in the Pact Broker. Marked previous deployed version as undeployed."
175
+ expect(subject.message).to include "Recorded deployment of Foo version 5556b8149bf8bac76bc30f50a8a2dd4c22c85f30 to test environment (target blue) in the Pact Broker."
172
176
  end
173
177
 
174
178
  context "when the output is json" do
@@ -204,14 +208,14 @@ RSpec.describe "recording a deployment", pact: true, skip: true do
204
208
 
205
209
  it "returns an error response" do
206
210
  expect(subject.success).to be false
207
- expect(subject.message).to eq "No environment found with name 'foo'. Available options: test"
211
+ expect(subject.message).to include "No environment found with name 'foo'. Available options: test"
208
212
  end
209
213
  end
210
214
 
211
215
  context "when the specified environment does exist" do
212
216
  it "returns an error response" do
213
217
  expect(subject.success).to be false
214
- expect(subject.message).to eq "Environment 'test' is not an available option for recording a deployment of Foo. Available options: prod, dev"
218
+ expect(subject.message).to include "Environment 'test' is not an available option for recording a deployment of Foo. Available options: prod, dev"
215
219
  end
216
220
  end
217
221
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pact_broker-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.42.0
4
+ version: 1.43.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Beth Skurrie
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-30 00:00:00.000000000 Z
11
+ date: 2021-06-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -407,7 +407,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
407
407
  - !ruby/object:Gem::Version
408
408
  version: '0'
409
409
  requirements: []
410
- rubygems_version: 3.2.18
410
+ rubygems_version: 3.2.19
411
411
  signing_key:
412
412
  specification_version: 4
413
413
  summary: See description