pact_broker-client 1.50.0 → 1.52.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: ebb0899f37221475b93ac43b01a535aa03a0f991fcf367556e83697f293873b8
4
- data.tar.gz: 1627a56a6fc1302c6bc381786c4a6f385485fa26a75cded5b3630ffb5afa1809
3
+ metadata.gz: c645adf22b85e738f227eec38baf09fe06241aeaeb4c75abc4c4558c66c2716f
4
+ data.tar.gz: e32efad31615c7335df1c36dea365fcc5e001574143a3df3d98e23c1c5c84c71
5
5
  SHA512:
6
- metadata.gz: 45636dfd9a5b865d870baf6147833562365e4fbf9fbbe80b9b0d5f34779defd3dacec69ddf1772167a65ab17da6389d8c7f183764e594fc23b85cecfe15b60ca
7
- data.tar.gz: 02d6f6a5a7514a32711179de4667bd57a247c440d6c95c046eacd291b0a31bf2eff89f9027bf79a0f14bf78fcb45aa9102b415c0945bee13477de539bfa4f4f8
6
+ metadata.gz: 02c18bab0a1d08d568524ccd0a48d526e2aebf3d17db29dc83884f82db4c4ebf9864fd2e6d3de01ab6b11febc658d94efe28a817f351266059771fff8a95a446
7
+ data.tar.gz: d647f077b021640b520babbc4e7ba5ed8bd4d460ebe826e98900f356bbd79dda96ee7c425d0ee6eeff7aa2648f996ded578f22a24708b8efdf5725cfd8fd97b9
@@ -27,7 +27,7 @@ jobs:
27
27
  strategy:
28
28
  fail-fast: false
29
29
  matrix:
30
- feature: ["", "publish_contracts"]
30
+ feature: [""]
31
31
  steps:
32
32
  - uses: actions/checkout@v2
33
33
  - uses: ruby/setup-ruby@v1
data/CHANGELOG.md CHANGED
@@ -1,3 +1,32 @@
1
+ <a name="v1.52.0"></a>
2
+ ### v1.52.0 (2021-09-29)
3
+
4
+ #### Features
5
+
6
+ * rename target to application-instance for record-deployment and record-undeployment (backwards compatible) ([53d23eb](/../../commit/53d23eb))
7
+
8
+ <a name="v1.51.2"></a>
9
+ ### v1.51.2 (2021-09-27)
10
+
11
+ #### Bug Fixes
12
+
13
+ * **deps**
14
+ * lock httparty to 0.18.1 ([1ab2d9c](/../../commit/1ab2d9c))
15
+
16
+ <a name="v1.51.1"></a>
17
+ ### v1.51.1 (2021-09-22)
18
+
19
+ #### Bug Fixes
20
+
21
+ * remove deprecated method of handling branches ([6d26487](/../../commit/6d26487))
22
+
23
+ <a name="v1.51.0"></a>
24
+ ### v1.51.0 (2021-09-22)
25
+
26
+ #### Features
27
+
28
+ * enable use of the new 'all in one' contracts publishing endpoint without a feature toggle ([6850ace](/../../commit/6850ace))
29
+
1
30
  <a name="v1.50.0"></a>
2
31
  ### v1.50.0 (2021-08-16)
3
32
 
data/README.md CHANGED
@@ -275,29 +275,33 @@ Usage:
275
275
  pact-broker record-deployment --environment=ENVIRONMENT -a, --pacticipant=PACTICIPANT -b, --broker-base-url=BROKER_BASE_URL -e, --version=VERSION
276
276
 
277
277
  Options:
278
- -a, --pacticipant=PACTICIPANT
278
+ -a, --pacticipant=PACTICIPANT
279
279
  # The name of the pacticipant that was deployed.
280
- -e, --version=VERSION
280
+ -e, --version=VERSION
281
281
  # The pacticipant version number that was deployed.
282
- --environment=ENVIRONMENT
282
+ --environment=ENVIRONMENT
283
283
  # The name of the environment that the pacticipant version was
284
284
  deployed to.
285
- [--target=TARGET]
286
- # Optional. The target of the deployment - a logical identifer
287
- required to differentiate deployments when there are multiple
288
- instances of the same application in an environment.
289
- -o, [--output=OUTPUT]
285
+ [--application-instance=APPLICATION_INSTANCE]
286
+ # Optional. The application instance to which the deployment has
287
+ occurred - a logical identifer required to differentiate
288
+ deployments when there are multiple instances of the same
289
+ application in an environment. This field was called 'target'
290
+ in a beta release.
291
+ [--target=TARGET]
292
+ # Renamed to application_instance
293
+ -o, [--output=OUTPUT]
290
294
  # json or text
291
295
  # Default: text
292
- -b, --broker-base-url=BROKER_BASE_URL
296
+ -b, --broker-base-url=BROKER_BASE_URL
293
297
  # The base URL of the Pact Broker
294
- -u, [--broker-username=BROKER_USERNAME]
298
+ -u, [--broker-username=BROKER_USERNAME]
295
299
  # Pact Broker basic auth username
296
- -p, [--broker-password=BROKER_PASSWORD]
300
+ -p, [--broker-password=BROKER_PASSWORD]
297
301
  # Pact Broker basic auth password
298
- -k, [--broker-token=BROKER_TOKEN]
302
+ -k, [--broker-token=BROKER_TOKEN]
299
303
  # Pact Broker bearer token
300
- -v, [--verbose], [--no-verbose]
304
+ -v, [--verbose], [--no-verbose]
301
305
  # Verbose output. Default: false
302
306
  ```
303
307
 
@@ -310,28 +314,34 @@ Usage:
310
314
  pact-broker record-undeployment --environment=ENVIRONMENT -a, --pacticipant=PACTICIPANT -b, --broker-base-url=BROKER_BASE_URL
311
315
 
312
316
  Options:
313
- -a, --pacticipant=PACTICIPANT
317
+ -a, --pacticipant=PACTICIPANT
314
318
  # The name of the pacticipant that was undeployed.
315
- --environment=ENVIRONMENT
319
+ --environment=ENVIRONMENT
316
320
  # The name of the environment that the pacticipant version was
317
321
  undeployed from.
318
- [--target=TARGET]
322
+ [--application-instance=APPLICATION_INSTANCE]
323
+ # Optional. The application instance from which the application
324
+ is being undeployed - a logical identifer required to
325
+ differentiate deployments when there are multiple instances of
326
+ the same application in an environment. This field was called
327
+ 'target' in a beta release.
328
+ [--target=TARGET]
319
329
  # Optional. The target that the application is being undeployed
320
330
  from - a logical identifer required to differentiate
321
331
  deployments when there are multiple instances of the same
322
332
  application in an environment.
323
- -o, [--output=OUTPUT]
333
+ -o, [--output=OUTPUT]
324
334
  # json or text
325
335
  # Default: text
326
- -b, --broker-base-url=BROKER_BASE_URL
336
+ -b, --broker-base-url=BROKER_BASE_URL
327
337
  # The base URL of the Pact Broker
328
- -u, [--broker-username=BROKER_USERNAME]
338
+ -u, [--broker-username=BROKER_USERNAME]
329
339
  # Pact Broker basic auth username
330
- -p, [--broker-password=BROKER_PASSWORD]
340
+ -p, [--broker-password=BROKER_PASSWORD]
331
341
  # Pact Broker basic auth password
332
- -k, [--broker-token=BROKER_TOKEN]
342
+ -k, [--broker-token=BROKER_TOKEN]
333
343
  # Pact Broker bearer token
334
- -v, [--verbose], [--no-verbose]
344
+ -v, [--verbose], [--no-verbose]
335
345
  # Verbose output. Default: false
336
346
  ```
337
347
 
@@ -469,8 +479,8 @@ Description:
469
479
  support for environments, deployments and releases. For documentation on how to use can-i-deploy with tags, please see
470
480
  https://docs.pact.io/pact_broker/client_cli/can_i_deploy_usage_with_tags/
471
481
 
472
- Before `can-i-deploy` can be used, the relevant environment resources must first be created in the Pact Broker using the `create-environment` command. The "test"
473
- and "production" environments will have been seeded for you. You can check the existing environments by running `pact-broker list-environments`. See
482
+ Before `can-i-deploy` can be used, the relevant environment resources must first be created in the Pact Broker using the `create-environment` command. The
483
+ "test" and "production" environments will have been seeded for you. You can check the existing environments by running `pact-broker list-environments`. See
474
484
  https://docs.pact.io/pact_broker/client_cli/readme#environments for more information.
475
485
 
476
486
  $ pact-broker create-environment --name "uat" --display-name "UAT" --no-production
@@ -480,8 +490,8 @@ Description:
480
490
 
481
491
  $ pact-broker record-deployment --pacticipant Foo --version 173153ae0 --environment uat
482
492
 
483
- Before an application is deployed or released to an environment, the can-i-deploy command must be run to check that the application version is safe to deploy with
484
- the versions of each integrated application that are already in that environment.
493
+ Before an application is deployed or released to an environment, the can-i-deploy command must be run to check that the application version is safe to deploy
494
+ with the versions of each integrated application that are already in that environment.
485
495
 
486
496
  $ pact-broker can-i-deploy --pacticipant PACTICIPANT --version VERSION --to-environment ENVIRONMENT
487
497
 
@@ -489,8 +499,8 @@ Description:
489
499
 
490
500
  $ pact-broker can-i-deploy --pacticipant Foo --version 173153ae0 --to-environment test
491
501
 
492
- Can-i-deploy can also be used to check if arbitrary versions have a successful verification. When asking "Can I deploy this application version with the latest version
493
- from the main branch of another application" it functions as a "can I merge" check.
502
+ Can-i-deploy can also be used to check if arbitrary versions have a successful verification. When asking "Can I deploy this application version with the
503
+ latest version from the main branch of another application" it functions as a "can I merge" check.
494
504
 
495
505
  $ pact-broker can-i-deploy --pacticipant Foo 173153ae0 \ --pacticipant Bar --latest main
496
506
 
@@ -628,8 +638,8 @@ Options:
628
638
  ```
629
639
 
630
640
  Description:
631
- Create a curl command that executes the request that you want your webhook to execute, then replace "curl" with "pact-broker create-webhook" and add the consumer,
632
- provider, event types and broker details. Note that the URL must be the first parameter when executing create-webhook.
641
+ Create a curl command that executes the request that you want your webhook to execute, then replace "curl" with "pact-broker create-webhook" and add the
642
+ consumer, provider, event types and broker details. Note that the URL must be the first parameter when executing create-webhook.
633
643
 
634
644
  Note that the -u option from the curl command clashes with the -u option from the pact-broker CLI. When used in this command, the -u will be used as a curl
635
645
  option. Please use the --broker-username or environment variable for the Pact Broker username.
@@ -686,9 +696,9 @@ Options:
686
696
  ```
687
697
 
688
698
  Description:
689
- Create a curl command that executes the request that you want your webhook to execute, then replace "curl" with "pact-broker create-or-update-webhook" and add the
690
- consumer, provider, event types and broker details. Note that the URL must be the first parameter when executing create-or-update-webhook and a uuid must
691
- also be provided. You can generate a valid UUID by using the `generate-uuid` command.
699
+ Create a curl command that executes the request that you want your webhook to execute, then replace "curl" with "pact-broker create-or-update-webhook" and
700
+ add the consumer, provider, event types and broker details. Note that the URL must be the first parameter when executing create-or-update-webhook and a uuid
701
+ must also be provided. You can generate a valid UUID by using the `generate-uuid` command.
692
702
 
693
703
  Note that the -u option from the curl command clashes with the -u option from the pact-broker CLI. When used in this command, the -u will be used as a curl
694
704
  option. Please use the --broker-username or environment variable for the Pact Broker username.
@@ -40,7 +40,7 @@
40
40
 
41
41
  * [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
42
42
 
43
- * [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
43
+ * [A request for the index resource](#a_request_for_the_index_resource_given_the_pb:publish-contracts_relations_exists_in_the_index_resource) given the pb:publish-contracts relations exists in the index resource
44
44
 
45
45
  * [A request for the index resource with the webhook relation](#a_request_for_the_index_resource_with_the_webhook_relation)
46
46
 
@@ -56,10 +56,6 @@
56
56
 
57
57
  * [A request to create a pacticipant](#a_request_to_create_a_pacticipant)
58
58
 
59
- * [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
60
-
61
- * [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
62
-
63
59
  * [A request to create a webhook for a consumer and provider](#a_request_to_create_a_webhook_for_a_consumer_and_provider_given_&#39;Condor&#39;_does_not_exist_in_the_pact-broker) given 'Condor' does not exist in the pact-broker
64
60
 
65
61
  * [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_&#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
@@ -100,6 +96,8 @@
100
96
 
101
97
  * [A request to publish a pact with method put](#a_request_to_publish_a_pact_with_method_put_given_the_&#39;Pricing_Service&#39;_and_&#39;Condor&#39;_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
102
98
 
99
+ * [A request to publish contracts](#a_request_to_publish_contracts)
100
+
103
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
104
102
 
105
103
  * [A request to record a release](#a_request_to_record_a_release_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
@@ -855,11 +853,11 @@ Pact Broker will respond with:
855
853
  }
856
854
  }
857
855
  ```
858
- <a name="a_request_for_the_index_resource_given_the_pb:pacticipant-version_relation_exists_in_the_index_resource"></a>
859
- Given **the pb:pacticipant-version relation exists in the index resource**, upon receiving **a request for the index resource** from Pact Broker Client, with
856
+ <a name="a_request_for_the_index_resource_given_the_pb:publish-contracts_relations_exists_in_the_index_resource"></a>
857
+ Given **the pb:publish-contracts relations exists in the index resource**, upon receiving **a request for the index resource** from Pact Broker Client, with
860
858
  ```json
861
859
  {
862
- "method": "get",
860
+ "method": "GET",
863
861
  "path": "/",
864
862
  "headers": {
865
863
  "Accept": "application/hal+json"
@@ -875,8 +873,8 @@ Pact Broker will respond with:
875
873
  },
876
874
  "body": {
877
875
  "_links": {
878
- "pb:pacticipant-version": {
879
- "href": "http://localhost:1234/HAL-REL-PLACEHOLDER-INDEX-PB-PACTICIPANT-VERSION-{pacticipant}-{version}"
876
+ "pb:publish-contracts": {
877
+ "href": "http://localhost:1234/HAL-REL-PLACEHOLDER-PB-PUBLISH-CONTRACTS"
880
878
  }
881
879
  }
882
880
  }
@@ -1134,74 +1132,6 @@ Pact Broker will respond with:
1134
1132
  }
1135
1133
  }
1136
1134
  ```
1137
- <a name="a_request_to_create_a_pacticipant_version_given_version_26f353580936ad3b9baddb17b00e84f33c69e7cb_of_pacticipant_Foo_does_exist"></a>
1138
- Given **version 26f353580936ad3b9baddb17b00e84f33c69e7cb of pacticipant Foo does exist**, upon receiving **a request to create a pacticipant version** from Pact Broker Client, with
1139
- ```json
1140
- {
1141
- "method": "put",
1142
- "path": "/HAL-REL-PLACEHOLDER-INDEX-PB-PACTICIPANT-VERSION-Foo-26f353580936ad3b9baddb17b00e84f33c69e7cb",
1143
- "headers": {
1144
- "Content-Type": "application/json",
1145
- "Accept": "application/hal+json"
1146
- },
1147
- "body": {
1148
- "branch": "main",
1149
- "buildUrl": "http://my-ci/builds/1"
1150
- }
1151
- }
1152
- ```
1153
- Pact Broker will respond with:
1154
- ```json
1155
- {
1156
- "status": 200,
1157
- "headers": {
1158
- "Content-Type": "application/hal+json;charset=utf-8"
1159
- },
1160
- "body": {
1161
- "number": "26f353580936ad3b9baddb17b00e84f33c69e7cb",
1162
- "buildUrl": "http://my-ci/builds/1",
1163
- "_links": {
1164
- "self": {
1165
- "href": "http://localhost:1234/some-url"
1166
- }
1167
- }
1168
- }
1169
- }
1170
- ```
1171
- <a name="a_request_to_create_a_pacticipant_version_given_version_26f353580936ad3b9baddb17b00e84f33c69e7cb_of_pacticipant_Foo_does_not_exist"></a>
1172
- Given **version 26f353580936ad3b9baddb17b00e84f33c69e7cb of pacticipant Foo does not exist**, upon receiving **a request to create a pacticipant version** from Pact Broker Client, with
1173
- ```json
1174
- {
1175
- "method": "put",
1176
- "path": "/HAL-REL-PLACEHOLDER-INDEX-PB-PACTICIPANT-VERSION-Foo-26f353580936ad3b9baddb17b00e84f33c69e7cb",
1177
- "headers": {
1178
- "Content-Type": "application/json",
1179
- "Accept": "application/hal+json"
1180
- },
1181
- "body": {
1182
- "branch": "main",
1183
- "buildUrl": "http://my-ci/builds/1"
1184
- }
1185
- }
1186
- ```
1187
- Pact Broker will respond with:
1188
- ```json
1189
- {
1190
- "status": 201,
1191
- "headers": {
1192
- "Content-Type": "application/hal+json;charset=utf-8"
1193
- },
1194
- "body": {
1195
- "number": "26f353580936ad3b9baddb17b00e84f33c69e7cb",
1196
- "buildUrl": "http://my-ci/builds/1",
1197
- "_links": {
1198
- "self": {
1199
- "href": "http://localhost:1234/some-url"
1200
- }
1201
- }
1202
- }
1203
- }
1204
- ```
1205
1135
  <a name="a_request_to_create_a_webhook_for_a_consumer_and_provider_given_&#39;Condor&#39;_does_not_exist_in_the_pact-broker"></a>
1206
1136
  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
1207
1137
  ```json
@@ -2119,6 +2049,75 @@ Pact Broker will respond with:
2119
2049
  }
2120
2050
  }
2121
2051
  ```
2052
+ <a name="a_request_to_publish_contracts"></a>
2053
+ Upon receiving **a request to publish contracts** from Pact Broker Client, with
2054
+ ```json
2055
+ {
2056
+ "method": "POST",
2057
+ "path": "/HAL-REL-PLACEHOLDER-PB-PUBLISH-CONTRACTS",
2058
+ "headers": {
2059
+ "Content-Type": "application/json",
2060
+ "Accept": "application/hal+json"
2061
+ },
2062
+ "body": {
2063
+ "pacticipantName": "Foo",
2064
+ "pacticipantVersionNumber": "5556b8149bf8bac76bc30f50a8a2dd4c22c85f30",
2065
+ "branch": "main",
2066
+ "tags": [
2067
+ "dev"
2068
+ ],
2069
+ "buildUrl": "http://build",
2070
+ "contracts": [
2071
+ {
2072
+ "consumerName": "Foo",
2073
+ "providerName": "Bar",
2074
+ "specification": "pact",
2075
+ "contentType": "application/json",
2076
+ "content": "eyJjb25zdW1lciI6eyJuYW1lIjoiRm9vIn0sInByb3ZpZGVyIjp7Im5hbWUiOiJCYXIifSwiaW50ZXJhY3Rpb25zIjpbeyJkZXNjcmlwdGlvbiI6ImFuIGV4YW1wbGUgcmVxdWVzdCIsInByb3ZpZGVyU3RhdGUiOiJhIHByb3ZpZGVyIHN0YXRlIiwicmVxdWVzdCI6eyJtZXRob2QiOiJHRVQiLCJwYXRoIjoiLyIsImhlYWRlcnMiOnt9fSwicmVzcG9uc2UiOnsic3RhdHVzIjoyMDAsImhlYWRlcnMiOnsiQ29udGVudC1UeXBlIjoiYXBwbGljYXRpb24vaGFsK2pzb24ifX19XSwibWV0YWRhdGEiOnsicGFjdFNwZWNpZmljYXRpb24iOnsidmVyc2lvbiI6IjIuMC4wIn19fQ==",
2077
+ "onConflict": "merge"
2078
+ }
2079
+ ]
2080
+ }
2081
+ }
2082
+ ```
2083
+ Pact Broker will respond with:
2084
+ ```json
2085
+ {
2086
+ "status": 200,
2087
+ "headers": {
2088
+ "Content-Type": "application/hal+json;charset=utf-8"
2089
+ },
2090
+ "body": {
2091
+ "_embedded": {
2092
+ "pacticipant": {
2093
+ "name": "Foo"
2094
+ },
2095
+ "version": {
2096
+ "number": "5556b8149bf8bac76bc30f50a8a2dd4c22c85f30",
2097
+ "buildUrl": "http://build"
2098
+ }
2099
+ },
2100
+ "logs": [
2101
+ {
2102
+ "level": "info",
2103
+ "message": "some message"
2104
+ }
2105
+ ],
2106
+ "_links": {
2107
+ "pb:pacticipant-version-tags": [
2108
+ {
2109
+ "name": "dev"
2110
+ }
2111
+ ],
2112
+ "pb:contracts": [
2113
+ {
2114
+ "href": "http://some-pact"
2115
+ }
2116
+ ]
2117
+ }
2118
+ }
2119
+ }
2120
+ ```
2122
2121
  <a name="a_request_to_record_a_deployment_given_version_5556b8149bf8bac76bc30f50a8a2dd4c22c85f30_of_pacticipant_Foo_exists_with_a_test_environment_available_for_deployment"></a>
2123
2122
  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
2124
2123
  ```json
@@ -2130,6 +2129,7 @@ Given **version 5556b8149bf8bac76bc30f50a8a2dd4c22c85f30 of pacticipant Foo exis
2130
2129
  "Accept": "application/hal+json"
2131
2130
  },
2132
2131
  "body": {
2132
+ "applicationInstance": "blue",
2133
2133
  "target": "blue"
2134
2134
  }
2135
2135
  }
@@ -14,16 +14,18 @@ module PactBroker
14
14
  method_option :pacticipant, required: true, aliases: "-a", desc: "The name of the pacticipant that was deployed."
15
15
  method_option :version, required: true, aliases: "-e", desc: "The pacticipant version number that was deployed."
16
16
  method_option :environment, required: true, desc: "The name of the environment that the pacticipant version was deployed to."
17
- method_option :target, default: nil, required: false, desc: "Optional. The target of the deployment - a logical identifer required to differentiate deployments when there are multiple instances of the same application in an environment."
17
+ method_option :application_instance, default: nil, required: false, desc: "Optional. The application instance to which the deployment has occurred - a logical identifer required to differentiate deployments when there are multiple instances of the same application in an environment. This field was called 'target' in a beta release."
18
+ method_option :target, hidden: true, default: nil, required: false, desc: "Renamed to application_instance"
18
19
  output_option_json_or_text
19
20
  shared_authentication_options
20
21
 
21
22
  def record_deployment
23
+ $stderr.puts("WARN: target has been renamed to application-instance") if options.target
22
24
  params = {
23
25
  pacticipant_name: options.pacticipant,
24
26
  version_number: options.version,
25
27
  environment_name: options.environment,
26
- target: options.target
28
+ application_instance: options.application_instance || options.target
27
29
  }
28
30
  execute_deployment_command(params, "RecordDeployment")
29
31
  end
@@ -32,15 +34,17 @@ module PactBroker
32
34
  long_desc "Note that use of this command is only required if you are permanently removing an application instance from an environment. It is not required if you are deploying over a previous version, as record-deployment will automatically mark the previously deployed version as undeployed for you. See #{RECORD_UNDEPLOYMENT_HELP_URL} for more information."
33
35
  method_option :pacticipant, required: true, aliases: "-a", desc: "The name of the pacticipant that was undeployed."
34
36
  method_option :environment, required: true, desc: "The name of the environment that the pacticipant version was undeployed from."
37
+ method_option :application_instance, default: nil, required: false, desc: "Optional. The application instance from which the application is being undeployed - a logical identifer required to differentiate deployments when there are multiple instances of the same application in an environment. This field was called 'target' in a beta release."
35
38
  method_option :target, default: nil, required: false, desc: "Optional. The target that the application is being undeployed from - a logical identifer required to differentiate deployments when there are multiple instances of the same application in an environment."
36
39
  output_option_json_or_text
37
40
  shared_authentication_options
38
41
 
39
42
  def record_undeployment
43
+ $stderr.puts("WARN: target has been renamed to application-instance") if options.target
40
44
  params = {
41
45
  pacticipant_name: options.pacticipant,
42
46
  environment_name: options.environment,
43
- target: options.target
47
+ application_instance: options.application_instance || options.target
44
48
  }
45
49
  execute_deployment_command(params, "RecordUndeployment")
46
50
  end
@@ -6,12 +6,12 @@ module PactBroker
6
6
  class RecordDeployment < PactBroker::Client::Deployments::RecordRelease
7
7
  def initialize(params, options, pact_broker_client_options)
8
8
  super
9
- @target = params.fetch(:target)
9
+ @application_instance = params.fetch(:application_instance)
10
10
  end
11
11
 
12
12
  private
13
13
 
14
- attr_reader :target
14
+ attr_reader :application_instance
15
15
 
16
16
  def action
17
17
  "deployment"
@@ -22,12 +22,13 @@ module PactBroker
22
22
  end
23
23
 
24
24
  def record_action_request_body
25
- { target: target }.compact
25
+ # for backwards compatibility with old broker
26
+ { applicationInstance: application_instance, target: application_instance }.compact
26
27
  end
27
28
 
28
29
  def result_text_message
29
- if target
30
- "#{super} (target #{target})"
30
+ if application_instance
31
+ "#{super} (application instance #{application_instance})"
31
32
  else
32
33
  super
33
34
  end
@@ -8,7 +8,7 @@ module PactBroker
8
8
  super
9
9
  @pacticipant_name = params.fetch(:pacticipant_name)
10
10
  @environment_name = params.fetch(:environment_name)
11
- @target = params.fetch(:target)
11
+ @application_instance = params.fetch(:application_instance)
12
12
  end
13
13
 
14
14
  private
@@ -21,7 +21,7 @@ module PactBroker
21
21
  end
22
22
  end
23
23
 
24
- attr_reader :pacticipant_name, :environment_name, :target
24
+ attr_reader :pacticipant_name, :environment_name, :application_instance
25
25
 
26
26
  def currently_deployed_versions_link
27
27
  environment_resource._link("pb:currently-deployed-deployed-versions", "pb:currently-deployed-versions") or raise PactBroker::Client::Error.new(not_supported_message)
@@ -31,14 +31,19 @@ module PactBroker
31
31
  @deployed_version_links ||= currently_deployed_versions_link.get!(pacticipant: pacticipant_name).embedded_entities!("deployedVersions")
32
32
  end
33
33
 
34
- def currently_deployed_version_entities_for_pacticipant_and_target
34
+ def currently_deployed_version_entities_for_pacticipant_and_instance
35
35
  currently_deployed_version_entities_for_pacticipant.select do | entity |
36
- entity.target == target
36
+ if application_instance
37
+ entity.applicationInstance == application_instance || entity.target == application_instance
38
+ else
39
+ entity.applicationInstance == nil && entity.target == nil
40
+ end
41
+
37
42
  end
38
43
  end
39
44
 
40
45
  def undeployed_versions_resources
41
- @undeployed_versions_resources ||= currently_deployed_version_entities_for_pacticipant_and_target.collect do | entity |
46
+ @undeployed_versions_resources ||= currently_deployed_version_entities_for_pacticipant_and_instance.collect do | entity |
42
47
  entity._link!("self").patch(currentlyDeployed: false)
43
48
  end
44
49
  end
@@ -75,7 +80,7 @@ module PactBroker
75
80
  message = "Recorded #{action} of #{pacticipant_name}"
76
81
  message = "#{message} version #{version.number}" if (version && version.number)
77
82
  message = "#{message} from #{environment_name} environment"
78
- message = "#{message} (target #{target})" if target
83
+ message = "#{message} (application instance #{application_instance})" if application_instance
79
84
  message
80
85
  end
81
86
 
@@ -92,19 +97,22 @@ module PactBroker
92
97
  "No pacticipant with name '#{pacticipant_name}' found."
93
98
  else
94
99
  if currently_deployed_version_entities_for_pacticipant.any?
95
- target_does_not_match_message
100
+ application_instance_does_not_match_message
96
101
  else
97
102
  "#{pacticipant_name} is not currently deployed to #{environment_name} environment. Cannot record undeployment."
98
103
  end
99
104
  end
100
105
  end
101
106
 
102
- def target_does_not_match_message
103
- potential_targets = currently_deployed_version_entities_for_pacticipant.collect(&:target).collect { |target| target || "<no target>"}
104
- if target
105
- "#{pacticipant_name} is not currently deployed to target '#{target}' in #{environment_name} environment. Please specify one of the following targets to record the undeployment from: #{potential_targets.join(", ")}"
107
+ def application_instance_does_not_match_message
108
+ potential_application_instances = currently_deployed_version_entities_for_pacticipant.collect{|e| e.applicationInstance || e.target }
109
+
110
+ if application_instance
111
+ omit_text = potential_application_instances.include?(nil) ? "omit the application instance to undeploy from the anonymous instance" : nil
112
+ specify_text = potential_application_instances.compact.any? ? "specify one of the following application instances to record the undeployment from: #{potential_application_instances.compact.join(", ")}" : nil
113
+ "#{pacticipant_name} is not currently deployed to application instance '#{application_instance}' in #{environment_name} environment. Please #{[omit_text, specify_text].compact.join(" or ")}."
106
114
  else
107
- "Please specify one of the following targets to record the undeployment from: #{potential_targets.join(", ")}"
115
+ "Please specify one of the following application instances to record the undeployment from: #{potential_application_instances.compact.join(", ")}"
108
116
  end
109
117
  end
110
118
 
@@ -28,7 +28,7 @@ module PactBroker
28
28
 
29
29
  def call
30
30
  validate
31
- if ENV.fetch("PACT_BROKER_FEATURES", "").include?("publish_contracts") && index_resource.can?("pb:publish-contracts")
31
+ if index_resource.can?("pb:publish-contracts")
32
32
  publish_pacts
33
33
  PactBroker::Client::CommandResult.new(success?, message)
34
34
  else
@@ -115,9 +115,8 @@ module PactBroker
115
115
  specification: "pact",
116
116
  contentType: "application/json",
117
117
  content: Base64.strict_encode64(pact_hash.to_json),
118
- writeMode: write_mode,
119
- onConflict: write_mode
120
- }
118
+ onConflict: on_conflict
119
+ }.compact
121
120
  end
122
121
  end
123
122
 
@@ -137,8 +136,8 @@ module PactBroker
137
136
  pact_files.collect(&:consumer_name).uniq
138
137
  end
139
138
 
140
- def write_mode
141
- options[:merge] ? "merge" : "overwrite"
139
+ def on_conflict
140
+ options[:merge] ? "merge" : nil
142
141
  end
143
142
 
144
143
  def validate