pact_broker-client 1.40.0 → 1.41.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/CHANGELOG.md +7 -0
  4. data/Gemfile +4 -0
  5. data/doc/pacts/markdown/Pact Broker Client - Pact Broker.md +2 -181
  6. data/lib/pact_broker/client/can_i_deploy.rb +20 -3
  7. data/lib/pact_broker/client/cli/broker.rb +13 -5
  8. data/lib/pact_broker/client/cli/record_deployment_long_desc.txt +0 -55
  9. data/lib/pact_broker/client/cli/version_selector_options_parser.rb +4 -0
  10. data/lib/pact_broker/client/colorize_notices.rb +31 -0
  11. data/lib/pact_broker/client/matrix.rb +4 -0
  12. data/lib/pact_broker/client/matrix/abbreviate_version_number.rb +15 -0
  13. data/lib/pact_broker/client/matrix/resource.rb +26 -1
  14. data/lib/pact_broker/client/matrix/text_formatter.rb +11 -8
  15. data/lib/pact_broker/client/publish_pacts.rb +6 -2
  16. data/lib/pact_broker/client/version.rb +1 -1
  17. data/lib/pact_broker/client/versions/record_deployment.rb +4 -4
  18. data/pact-broker-client.gemspec +1 -0
  19. data/script/approve-all.sh +6 -0
  20. data/script/publish-pact.sh +12 -9
  21. data/spec/fixtures/approvals/can_i_deploy_ignore.approved.txt +13 -0
  22. data/spec/lib/pact_broker/client/can_i_deploy_spec.rb +47 -5
  23. data/spec/lib/pact_broker/client/cli/broker_can_i_deploy_spec.rb +3 -3
  24. data/spec/lib/pact_broker/client/cli/version_selector_options_parser_spec.rb +21 -0
  25. data/spec/lib/pact_broker/client/versions/record_deployment_spec.rb +2 -2
  26. data/spec/pacts/pact_broker_client-pact_broker.json +2 -182
  27. data/spec/service_providers/pact_broker_client_matrix_ignore_spec.rb +98 -0
  28. data/spec/service_providers/publish_pacts_spec.rb +2 -1
  29. data/spec/service_providers/record_deployment_spec.rb +5 -6
  30. data/spec/spec_helper.rb +2 -1
  31. data/spec/support/approvals.rb +26 -0
  32. data/spec/support/shared_context.rb +6 -2
  33. metadata +32 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 71ffd6b9522aa3c9ccb2bff18e3fa9b0a723aa480e312be3aa659ff3d7f07e32
4
- data.tar.gz: 4e6d7034e9bb8b1a85e64afda22fe1ee723842da63c5d67d5586c37b41a4c9a5
3
+ metadata.gz: b929ba48b8f21f7cafeb339e925fac9ecf7a4a83cd3392f5170c769c725998c3
4
+ data.tar.gz: 1b50eef690671dfdf9a78f1bb8da0f2f1e58cf380b199a554b5a9e770d40a825
5
5
  SHA512:
6
- metadata.gz: 9139f502e90e33eb8f617aac7f49a3ca0ee92f149bc7b81849530956fb861b88425bd63a1fb9f0a7fdc0ff687112dee2c8b297832083146d88266fc5e7c8608a
7
- data.tar.gz: bff2cfc3be3e1032462afc67d34fcc1afbfdb42ceebd1c79abfe440f7f8f1f6c17e74a07b6cb9c6a0cc83df99d578cb0eb78afa99fab73871a4c23c7be24def9
6
+ metadata.gz: e527702e1d7d9cc3644f3c4db48c7e02060435699b0104f9048ab6142228475405fac9abea025c713bbf8a3a15b71660a56973515b72464814ff8dee62518289
7
+ data.tar.gz: 0b81d80a4ab02de7f7d71a7e5c991a6e322731c1803c7c85fd0b53379d92f4739e3296c0acd76cf528567b14147fb3743c352322104da46e4064116bc531514b
data/.gitignore CHANGED
@@ -2,6 +2,7 @@
2
2
  *.rbc
3
3
  .bundle
4
4
  .config
5
+ .approvals
5
6
  coverage
6
7
  InstalledFiles
7
8
  lib/bundler/man
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ <a name="v1.41.0"></a>
2
+ ### v1.41.0 (2021-05-25)
3
+
4
+ #### Features
5
+
6
+ * update colours of pact publish output ([2a51e37](/../../commit/2a51e37))
7
+
1
8
  <a name="v1.40.0"></a>
2
9
  ### v1.40.0 (2021-04-26)
3
10
 
data/Gemfile CHANGED
@@ -10,3 +10,7 @@ if ENV['X_PACT_DEVELOPMENT'] == 'true'
10
10
  gem 'pact-mock_service', path: '../pact-mock_service'
11
11
  gem 'pact-support', path: '../pact-support'
12
12
  end
13
+
14
+ group :development do
15
+ gem 'pry-byebug'
16
+ end
@@ -2,12 +2,6 @@
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
-
11
5
  * [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)
12
6
 
13
7
  * [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
@@ -26,8 +20,6 @@
26
20
 
27
21
  * [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
28
22
 
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
-
31
23
  * [A request for the index resource](#a_request_for_the_index_resource)
32
24
 
33
25
  * [A request for the index resource](#a_request_for_the_index_resource_given_the_pacticipant_relations_are_present) given the pacticipant relations are present
@@ -36,8 +28,6 @@
36
28
 
37
29
  * [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
38
30
 
39
- * [A request for the index resource](#a_request_for_the_index_resource_given_the_pb:pacticipant-version_and_pb:environments_relations_exist_in_the_index_resource) given the pb:pacticipant-version and pb:environments relations exist in the index resource
40
-
41
31
  * [A request for the index resource](#a_request_for_the_index_resource_given_the_pb:pacticipant-version_relation_exists_in_the_index_resource) given the pb:pacticipant-version relation exists in the index resource
42
32
 
43
33
  * [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
@@ -96,8 +86,6 @@
96
86
 
97
87
  * [A request to publish contracts](#a_request_to_publish_contracts)
98
88
 
99
- * [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
100
-
101
89
  * [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
102
90
 
103
91
  * [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
@@ -130,87 +118,6 @@
130
118
 
131
119
  #### Interactions
132
120
 
133
- <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>
134
- 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
135
- ```json
136
- {
137
- "method": "GET",
138
- "path": "/HAL-REL-PLACEHOLDER-PB-PACTICIPANT-VERSION-Foo-5556b8149bf8bac76bc30f50a8a2dd4c22c85f30",
139
- "headers": {
140
- "Accept": "application/hal+json"
141
- }
142
- }
143
- ```
144
- Pact Broker will respond with:
145
- ```json
146
- {
147
- "status": 200,
148
- "headers": {
149
- "Content-Type": "application/hal+json;charset=utf-8"
150
- },
151
- "body": {
152
- "_links": {
153
- "pb:record-deployment": [
154
- {
155
- "name": "prod",
156
- "href": "href"
157
- },
158
- {
159
- "name": "dev",
160
- "href": "href"
161
- }
162
- ]
163
- }
164
- }
165
- }
166
- ```
167
- <a name="a_request_for_a_pacticipant_version_given_version_5556b8149bf8bac76bc30f50a8a2dd4c22c85f30_of_pacticipant_Foo_exists_with_a_test_environment_available_for_deployment"></a>
168
- 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
169
- ```json
170
- {
171
- "method": "GET",
172
- "path": "/HAL-REL-PLACEHOLDER-PB-PACTICIPANT-VERSION-Foo-5556b8149bf8bac76bc30f50a8a2dd4c22c85f30",
173
- "headers": {
174
- "Accept": "application/hal+json"
175
- }
176
- }
177
- ```
178
- Pact Broker will respond with:
179
- ```json
180
- {
181
- "status": 200,
182
- "headers": {
183
- "Content-Type": "application/hal+json;charset=utf-8"
184
- },
185
- "body": {
186
- "_links": {
187
- "pb:record-deployment": [
188
- {
189
- "name": "test",
190
- "href": "http://localhost:1234/HAL-REL-PLACEHOLDER-PB-RECORD-DEPLOYMENT-FOO-5556B8149BF8BAC76BC30F50A8A2DD4C22C85F30-TEST"
191
- }
192
- ]
193
- }
194
- }
195
- }
196
- ```
197
- <a name="a_request_for_a_pacticipant_version_given_version_5556b8149bf8bac76bc30f50a8a2dd4c22c85f30_of_pacticipant_Foo_does_not_exist"></a>
198
- Given **version 5556b8149bf8bac76bc30f50a8a2dd4c22c85f30 of pacticipant Foo does not exist**, upon receiving **a request for a pacticipant version** from Pact Broker Client, with
199
- ```json
200
- {
201
- "method": "GET",
202
- "path": "/HAL-REL-PLACEHOLDER-PB-PACTICIPANT-VERSION-Foo-5556b8149bf8bac76bc30f50a8a2dd4c22c85f30",
203
- "headers": {
204
- "Accept": "application/hal+json"
205
- }
206
- }
207
- ```
208
- Pact Broker will respond with:
209
- ```json
210
- {
211
- "status": 404
212
- }
213
- ```
214
121
  <a name="a_request_for_the_compatibility_matrix_for_a_pacticipant_that_does_not_exist"></a>
215
122
  Upon receiving **a request for the compatibility matrix for a pacticipant that does not exist** from Pact Broker Client, with
216
123
  ```json
@@ -632,36 +539,6 @@ Pact Broker will respond with:
632
539
  }
633
540
  }
634
541
  ```
635
- <a name="a_request_for_the_environments_given_an_environment_with_name_test_exists"></a>
636
- Given **an environment with name test exists**, upon receiving **a request for the environments** from Pact Broker Client, with
637
- ```json
638
- {
639
- "method": "GET",
640
- "path": "/HAL-REL-PLACEHOLDER-PB-ENVIRONMENTS",
641
- "headers": {
642
- "Accept": "application/hal+json"
643
- }
644
- }
645
- ```
646
- Pact Broker will respond with:
647
- ```json
648
- {
649
- "status": 200,
650
- "headers": {
651
- "Content-Type": "application/hal+json;charset=utf-8"
652
- },
653
- "body": {
654
- "_links": {
655
- "pb:environments": [
656
- {
657
- "name": "test",
658
- "href": "href"
659
- }
660
- ]
661
- }
662
- }
663
- }
664
- ```
665
542
  <a name="a_request_for_the_index_resource"></a>
666
543
  Upon receiving **a request for the index resource** from Pact Broker Client, with
667
544
  ```json
@@ -779,36 +656,6 @@ Pact Broker will respond with:
779
656
  }
780
657
  }
781
658
  ```
782
- <a name="a_request_for_the_index_resource_given_the_pb:pacticipant-version_and_pb:environments_relations_exist_in_the_index_resource"></a>
783
- 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
784
- ```json
785
- {
786
- "method": "GET",
787
- "path": "/",
788
- "headers": {
789
- "Accept": "application/hal+json"
790
- }
791
- }
792
- ```
793
- Pact Broker will respond with:
794
- ```json
795
- {
796
- "status": 200,
797
- "headers": {
798
- "Content-Type": "application/hal+json;charset=utf-8"
799
- },
800
- "body": {
801
- "_links": {
802
- "pb:pacticipant-version": {
803
- "href": "http://localhost:1234/HAL-REL-PLACEHOLDER-PB-PACTICIPANT-VERSION-{pacticipant}-{version}"
804
- },
805
- "pb:environments": {
806
- "href": "http://localhost:1234/HAL-REL-PLACEHOLDER-PB-ENVIRONMENTS"
807
- }
808
- }
809
- }
810
- }
811
- ```
812
659
  <a name="a_request_for_the_index_resource_given_the_pb:pacticipant-version_relation_exists_in_the_index_resource"></a>
813
660
  Given **the pb:pacticipant-version relation exists in the index resource**, upon receiving **a request for the index resource** from Pact Broker Client, with
814
661
  ```json
@@ -1984,7 +1831,8 @@ Upon receiving **a request to publish contracts** from Pact Broker Client, with
1984
1831
  "specification": "pact",
1985
1832
  "contentType": "application/json",
1986
1833
  "content": "eyJjb25zdW1lciI6eyJuYW1lIjoiRm9vIn0sInByb3ZpZGVyIjp7Im5hbWUiOiJCYXIifSwiaW50ZXJhY3Rpb25zIjpbeyJkZXNjcmlwdGlvbiI6ImFuIGV4YW1wbGUgcmVxdWVzdCIsInByb3ZpZGVyU3RhdGUiOiJhIHByb3ZpZGVyIHN0YXRlIiwicmVxdWVzdCI6eyJtZXRob2QiOiJHRVQiLCJwYXRoIjoiLyIsImhlYWRlcnMiOnt9fSwicmVzcG9uc2UiOnsic3RhdHVzIjoyMDAsImhlYWRlcnMiOnsiQ29udGVudC1UeXBlIjoiYXBwbGljYXRpb24vaGFsK2pzb24ifX19XSwibWV0YWRhdGEiOnsicGFjdFNwZWNpZmljYXRpb24iOnsidmVyc2lvbiI6IjIuMC4wIn19fQ==",
1987
- "writeMode": "overwrite"
1834
+ "writeMode": "overwrite",
1835
+ "onConflict": "overwrite"
1988
1836
  }
1989
1837
  ]
1990
1838
  }
@@ -2028,33 +1876,6 @@ Pact Broker will respond with:
2028
1876
  }
2029
1877
  }
2030
1878
  ```
2031
- <a name="a_request_to_record_a_deployment_given_version_5556b8149bf8bac76bc30f50a8a2dd4c22c85f30_of_pacticipant_Foo_exists_with_a_test_environment_available_for_deployment"></a>
2032
- 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
2033
- ```json
2034
- {
2035
- "method": "POST",
2036
- "path": "/HAL-REL-PLACEHOLDER-PB-RECORD-DEPLOYMENT-FOO-5556B8149BF8BAC76BC30F50A8A2DD4C22C85F30-TEST",
2037
- "headers": {
2038
- "Content-Type": "application/json",
2039
- "Accept": "application/hal+json"
2040
- },
2041
- "body": {
2042
- "replacedPreviousDeployedVersion": true
2043
- }
2044
- }
2045
- ```
2046
- Pact Broker will respond with:
2047
- ```json
2048
- {
2049
- "status": 201,
2050
- "headers": {
2051
- "Content-Type": "application/hal+json;charset=utf-8"
2052
- },
2053
- "body": {
2054
- "replacedPreviousDeployedVersion": true
2055
- }
2056
- }
2057
- ```
2058
1879
  <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>
2059
1880
  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
2060
1881
  ```json
@@ -3,6 +3,7 @@ require 'pact_broker/client/pact_broker_client'
3
3
  require 'pact_broker/client/retry'
4
4
  require 'pact_broker/client/matrix/formatter'
5
5
  require 'term/ansicolor'
6
+ require 'pact_broker/client/colorize_notices'
6
7
 
7
8
  module PactBroker
8
9
  module Client
@@ -32,7 +33,7 @@ module PactBroker
32
33
  def call
33
34
  create_result(fetch_matrix_with_retries)
34
35
  rescue PactBroker::Client::Error => e
35
- Result.new(false, e.message)
36
+ Result.new(false, Term::ANSIColor.red(e.message))
36
37
  rescue StandardError => e
37
38
  Result.new(false, "Error retrieving matrix. #{e.class} - #{e.message}\n#{e.backtrace.join("\n")}")
38
39
  end
@@ -52,7 +53,7 @@ module PactBroker
52
53
  def success_message(matrix)
53
54
  message = format_matrix(matrix)
54
55
  if format != 'json'
55
- message = 'Computer says yes \o/ ' + message + "\n\n" + Term::ANSIColor.green(matrix.reason)
56
+ message = warning(matrix) + Term::ANSIColor.green('Computer says yes \o/ ') + message + "\n\n" + notice_or_reason(matrix, :green)
56
57
  end
57
58
  message
58
59
  end
@@ -60,11 +61,19 @@ module PactBroker
60
61
  def failure_message(matrix)
61
62
  message = format_matrix(matrix)
62
63
  if format != 'json'
63
- message = 'Computer says no ¯\_(ツ)_/¯ ' + message + "\n\n" + Term::ANSIColor.red(matrix.reason)
64
+ message = warning(matrix) + Term::ANSIColor.red('Computer says no ¯\_(ツ)_/¯ ') + message + "\n\n" + notice_or_reason(matrix, :red)
64
65
  end
65
66
  message
66
67
  end
67
68
 
69
+ def notice_or_reason(matrix, reason_color)
70
+ if matrix.notices
71
+ PactBroker::Client::ColorizeNotices.call(matrix.notices).join("\n")
72
+ else
73
+ Term::ANSIColor.send(reason_color, matrix.reason)
74
+ end
75
+ end
76
+
68
77
  def format_matrix(matrix)
69
78
  formatted_matrix = Matrix::Formatter.call(matrix, format)
70
79
  if format != 'json' && formatted_matrix.size > 0
@@ -131,6 +140,14 @@ module PactBroker
131
140
  raise PactBroker::Client::Error.new("This version of the Pact Broker does not provide a count of the unknown verification results. Please upgrade your Broker to >= v2.23.4")
132
141
  end
133
142
  end
143
+
144
+ def warning(matrix)
145
+ if matrix_options[:ignore_selectors] && matrix_options[:ignore_selectors].any? && !matrix.supports_ignore?
146
+ Term::ANSIColor.yellow("WARN: This version of the Pact Broker does not support ignoring pacticipants. Please upgrade your Broker to >= 2.80.0") + "\n\n"
147
+ else
148
+ ""
149
+ end
150
+ end
134
151
  end
135
152
  end
136
153
  end
@@ -19,6 +19,10 @@ module PactBroker
19
19
 
20
20
  method_option :pacticipant, required: true, aliases: "-a", desc: "The pacticipant name. Use once for each pacticipant being checked."
21
21
  method_option :version, required: false, aliases: "-e", desc: "The pacticipant version. Must be entered after the --pacticipant that it relates to."
22
+
23
+ if ENV.fetch("PACT_BROKER_FEATURES", "").include?("ignore")
24
+ 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."
25
+ end
22
26
  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."
23
27
  method_option :to, required: false, banner: 'TAG', desc: "This is too hard to explain in a short sentence. Look at the examples.", default: nil
24
28
  method_option :to_environment, required: false, banner: 'ENVIRONMENT', desc: "The environment into which the pacticipant(s) are to be deployed", default: nil, hide: true
@@ -34,10 +38,15 @@ module PactBroker
34
38
  require 'pact_broker/client/can_i_deploy'
35
39
 
36
40
  validate_credentials
37
- selectors = VersionSelectorOptionsParser.call(ARGV)
41
+ selectors = VersionSelectorOptionsParser.call(ARGV).select { |s| !s[:ignore] }
42
+ ignore_selectors = if ENV.fetch("PACT_BROKER_FEATURES", "").include?("ignore")
43
+ VersionSelectorOptionsParser.call(ARGV).select { |s| s[:ignore] }
44
+ else
45
+ []
46
+ end
38
47
  validate_can_i_deploy_selectors(selectors)
39
48
  can_i_deploy_options = { output: options.output, retry_while_unknown: options.retry_while_unknown, retry_interval: options.retry_interval }
40
- result = CanIDeploy.call(options.broker_base_url, selectors, { to_tag: options.to, to_environment: options.to_environment, limit: options.limit }, can_i_deploy_options, pact_broker_client_options)
49
+ result = CanIDeploy.call(options.broker_base_url, selectors, { to_tag: options.to, to_environment: options.to_environment, limit: options.limit, ignore_selectors: ignore_selectors }, can_i_deploy_options, pact_broker_client_options)
41
50
  $stdout.puts result.message
42
51
  $stdout.flush
43
52
  exit(can_i_deploy_exit_status) unless result.success
@@ -174,12 +183,11 @@ module PactBroker
174
183
  if ENV.fetch("PACT_BROKER_FEATURES", "").include?("deployments")
175
184
 
176
185
  ignored_and_hidden_potential_options_from_environment_variables
177
- desc "record-deployment", "Record deployment of a pacticipant version to an environment"
178
- long_desc File.read(File.join(__dir__, 'record_deployment_long_desc.txt'))
186
+ desc "record-deployment", "Record deployment of a pacticipant version to an environment. See https://docs.pact.io/go/record_deployment for more information."
179
187
  method_option :pacticipant, required: true, aliases: "-a", desc: "The name of the pacticipant that was deployed."
180
188
  method_option :version, required: true, aliases: "-e", desc: "The pacticipant version number that was deployed."
181
189
  method_option :environment, required: true, desc: "The name of the environment that the pacticipant version was deployed to."
182
- method_option :target, default: nil, required: false, desc: "The target of the deployment - a logical identifer that represents where the application version was deployed to. See the usage docs for information on when to use this."
190
+ 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."
183
191
  method_option :output, aliases: "-o", desc: "json or text", default: 'text'
184
192
  shared_authentication_options
185
193
 
@@ -1,55 +0,0 @@
1
- The record-deployment command is used to allow the Pact Broker to keep track of which version(s) of an application are currently deployed in each environment. It is used to keep track of applications that are deployed to known instances. If you are releasing a client library or mobile application to a repository or application store, please use record-release instead.
2
-
3
- ## Examples
4
-
5
-
6
- record-deployment --pacticipant Foo --version 6897aa95e --environment production
7
- record-deployment --pacticipant Foo --version 6897aa95e --environment production --target blue
8
- record-deployment --pacticipant Foo --version 6897aa95e --environment production --target green
9
-
10
- ## Target
11
-
12
- The "target" field is used to distinguish between deployed versions of an application within the same environment, and most importantly, to identify which previously deployed version has been replaced by the current deployment. The Pact Broker only allows one unique combination of pacticipant/environment/target to be considered the "currently deployed" one, and any call to record a deployment will cause the previously deployed version with the same pacticipant/environment/target to be automatically marked as undeployed (mimicking the real world process of "deploying over" a previous version).
13
-
14
- ### Use cases
15
-
16
- #### There is a single instance of an application deployed within an environment and deployments of integrated applications are NOT likely to happen during the deployment window of this application
17
-
18
- eg.
19
-
20
- * the window of time when there are multiple versions in prod is small
21
- * or there aren't many other integrations
22
- * or deployments happen rarely
23
- * or the same team controls all the deployments and generally only runs one deployment at a time
24
-
25
- In this case, there is no need to specify a target. The call to record deployment should be done at the end of the deployment and it will automatically mark the version of Foo that was previously the currently deployed version as undeployed. Only one version of the pacticipant is ever considered to be currently deployed at a time.
26
-
27
- eg.
28
-
29
- # actual call to deploy here...
30
- record-deployment --pacticipant Foo --version 6897aa95e --environment production
31
-
32
- #### There is a single instance of an application deployed within an environment and but deployments of integrated applications ARE likely to happen during the deployment window of this application
33
-
34
- eg.
35
- * the window of time when there are multiple versions in prod is large
36
- * or there are many integrations
37
- * or deployments happen often
38
- * or there are many different teams deploying and deployments aren't coordinated
39
-
40
- To allow multiple versions to be considered currently deployed at the same time, use two different targets, and call the first record-deployment at the start of the deployment process and a second one at the end.
41
-
42
- eg.
43
-
44
- This will use the targets "blue" and "green" to model stages of the deployment.
45
-
46
- record-deployment --pacticipant Foo --version 6897aa95e --environment production --target blue
47
- # actual call to deploy here...
48
- record-deployment --pacticipant Foo --version 6897aa95e --environment production --target green
49
-
50
- After the first call to record-deployment, there will be two versions considered currently deployed - the "blue" one that was just recorded, and the one from the previous "green" deployment. After the second call to record-deployment, there is only one version considered currently deployed - both "blue" and "green" targets will be have version 6897aa95e deployed to them.
51
-
52
-
53
- #### There are multiple permanent application versions deployed to the same environment
54
-
55
- TBC
@@ -12,6 +12,8 @@ module PactBroker
12
12
  case word
13
13
  when "--pacticipant", "-a"
14
14
  selectors << {}
15
+ when "--ignore"
16
+ selectors << { ignore: true }
15
17
  when "--latest", "-l"
16
18
  selectors << { pacticipant: nil } if selectors.empty?
17
19
  selectors.last[:latest] = true
@@ -21,6 +23,8 @@ module PactBroker
21
23
  case previous_option
22
24
  when "--pacticipant", "-a"
23
25
  selectors.last[:pacticipant] = word
26
+ when "--ignore"
27
+ selectors.last[:pacticipant] = word
24
28
  when "--version", "-e"
25
29
  selectors << { pacticipant: nil } if selectors.empty?
26
30
  selectors.last[:version] = word