pact_broker-client 1.36.0 → 1.37.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d55a0e281744620059c94153234610bf5368b178eff81765250a1b31b00ef124
4
- data.tar.gz: 42edd3c93f27dc59e498e52f36628158ac79bb8d7aa72a4b469ac69ec5734e00
3
+ metadata.gz: 780fdf6ce281a9e3d94de58bb68705d0aa4b9b9fb7262ae1331c246c8dda5d6a
4
+ data.tar.gz: f15abe101f78db4245f654f2f2717d8b78be861146769c83e32a655e43c3ecc8
5
5
  SHA512:
6
- metadata.gz: af0ca16aa9d4f2732ac72b42a102d4567d5a0541510967bfa38a4b2d3302f6d40e17f81af6c444cf93c7710edc583da4715f39aebdb736e471d7cc26e67503d6
7
- data.tar.gz: e276cb64d985c93dcb55185c6ed9b61fc8c392a90d28cf7fc4b49246f986503005d111c8f0802166364f316bf3bde100d2d71a36f533d899e32c00ff76681542
6
+ metadata.gz: 27c3f50858c65ea0fc07a0b88c8eee758cfeb09f37c81d01d767a040ad51b377b43dd6fc080e9ae4f08dae4d10c379a9cda9b9d1dc456f680e06f2fc87860543
7
+ data.tar.gz: 6ce9d5caf203b2b41d5fd665f84b43109bf0ebec81019bb2747de2723de6f0b60cc38ecadd6e6cad7a4cd43e625ea96c595475a9c8f48f8b75c3c1180ff960db
@@ -4,6 +4,7 @@ on:
4
4
  repository_dispatch:
5
5
  types:
6
6
  - release-triggered
7
+ workflow_dispatch:
7
8
 
8
9
  jobs:
9
10
  test:
data/CHANGELOG.md CHANGED
@@ -1,3 +1,14 @@
1
+ <a name="v1.37.0"></a>
2
+ ### v1.37.0 (2021-03-01)
3
+
4
+ #### Features
5
+
6
+ * add record-deployment ([6e5e208](/../../commit/6e5e208))
7
+
8
+ #### Bug Fixes
9
+
10
+ * use refinement to add compact to Hash ([c2c1cab](/../../commit/c2c1cab))
11
+
1
12
  <a name="v1.36.0"></a>
2
13
  ### v1.36.0 (2021-02-21)
3
14
 
data/Rakefile CHANGED
@@ -31,6 +31,8 @@ end
31
31
  desc 'List provider states'
32
32
  task 'pact:list_provider_states' do
33
33
  require 'json'
34
+ require 'pact_broker/client/backports'
35
+
34
36
  puts Dir.glob("spec/pacts/**.json").collect { | pact_file |
35
37
  puts pact_file
36
38
  JSON.parse(File.read(pact_file))['interactions'].collect{ | interaction| interaction['providerState'] }
@@ -2,6 +2,12 @@
2
2
 
3
3
  #### Requests from Pact Broker Client to Pact Broker
4
4
 
5
+ * [A request for a pacticipant version](#a_request_for_a_pacticipant_version_given_version_5556b8149bf8bac76bc30f50a8a2dd4c22c85f30_of_pacticipant_Foo_exists_with_2_environments_that_aren&#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 with the webhook relation](#a_request_for_the_index_resource_with_the_webhook_relation)
@@ -82,6 +92,8 @@
82
92
 
83
93
  * [A request to publish a pact with method put](#a_request_to_publish_a_pact_with_method_put_given_the_&#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
84
94
 
95
+ * [A request to record a deployment](#a_request_to_record_a_deployment_given_version_5556b8149bf8bac76bc30f50a8a2dd4c22c85f30_of_pacticipant_Foo_exists_with_a_test_environment_available_for_deployment) given version 5556b8149bf8bac76bc30f50a8a2dd4c22c85f30 of pacticipant Foo exists with a test environment available for deployment
96
+
85
97
  * [A request to register the repository URL of a pacticipant](#a_request_to_register_the_repository_URL_of_a_pacticipant_given_the_&#39;Pricing_Service&#39;_already_exists_in_the_pact-broker) given the 'Pricing Service' already exists in the pact-broker
86
98
 
87
99
  * [A request to register the repository URL of a pacticipant](#a_request_to_register_the_repository_URL_of_a_pacticipant_given_the_&#39;Pricing_Service&#39;_does_not_exist_in_the_pact-broker) given the 'Pricing Service' does not exist in the pact-broker
@@ -114,6 +126,87 @@
114
126
 
115
127
  #### Interactions
116
128
 
129
+ <a name="a_request_for_a_pacticipant_version_given_version_5556b8149bf8bac76bc30f50a8a2dd4c22c85f30_of_pacticipant_Foo_exists_with_2_environments_that_aren&#39;t_test_available_for_deployment"></a>
130
+ Given **version 5556b8149bf8bac76bc30f50a8a2dd4c22c85f30 of pacticipant Foo exists with 2 environments that aren't test available for deployment**, upon receiving **a request for a pacticipant version** from Pact Broker Client, with
131
+ ```json
132
+ {
133
+ "method": "GET",
134
+ "path": "/HAL-REL-PLACEHOLDER-PB-PACTICIPANT-VERSION-Foo-5556b8149bf8bac76bc30f50a8a2dd4c22c85f30",
135
+ "headers": {
136
+ "Accept": "application/hal+json"
137
+ }
138
+ }
139
+ ```
140
+ Pact Broker will respond with:
141
+ ```json
142
+ {
143
+ "status": 200,
144
+ "headers": {
145
+ "Content-Type": "application/hal+json;charset=utf-8"
146
+ },
147
+ "body": {
148
+ "_links": {
149
+ "pb:record-deployment": [
150
+ {
151
+ "name": "prod",
152
+ "href": "href"
153
+ },
154
+ {
155
+ "name": "dev",
156
+ "href": "href"
157
+ }
158
+ ]
159
+ }
160
+ }
161
+ }
162
+ ```
163
+ <a name="a_request_for_a_pacticipant_version_given_version_5556b8149bf8bac76bc30f50a8a2dd4c22c85f30_of_pacticipant_Foo_exists_with_a_test_environment_available_for_deployment"></a>
164
+ Given **version 5556b8149bf8bac76bc30f50a8a2dd4c22c85f30 of pacticipant Foo exists with a test environment available for deployment**, upon receiving **a request for a pacticipant version** from Pact Broker Client, with
165
+ ```json
166
+ {
167
+ "method": "GET",
168
+ "path": "/HAL-REL-PLACEHOLDER-PB-PACTICIPANT-VERSION-Foo-5556b8149bf8bac76bc30f50a8a2dd4c22c85f30",
169
+ "headers": {
170
+ "Accept": "application/hal+json"
171
+ }
172
+ }
173
+ ```
174
+ Pact Broker will respond with:
175
+ ```json
176
+ {
177
+ "status": 200,
178
+ "headers": {
179
+ "Content-Type": "application/hal+json;charset=utf-8"
180
+ },
181
+ "body": {
182
+ "_links": {
183
+ "pb:record-deployment": [
184
+ {
185
+ "name": "test",
186
+ "href": "http://localhost:1234/HAL-REL-PLACEHOLDER-PB-RECORD-DEPLOYMENT-FOO-5556B8149BF8BAC76BC30F50A8A2DD4C22C85F30-TEST"
187
+ }
188
+ ]
189
+ }
190
+ }
191
+ }
192
+ ```
193
+ <a name="a_request_for_a_pacticipant_version_given_version_5556b8149bf8bac76bc30f50a8a2dd4c22c85f30_of_pacticipant_Foo_does_not_exist"></a>
194
+ Given **version 5556b8149bf8bac76bc30f50a8a2dd4c22c85f30 of pacticipant Foo does not exist**, upon receiving **a request for a pacticipant version** from Pact Broker Client, with
195
+ ```json
196
+ {
197
+ "method": "GET",
198
+ "path": "/HAL-REL-PLACEHOLDER-PB-PACTICIPANT-VERSION-Foo-5556b8149bf8bac76bc30f50a8a2dd4c22c85f30",
199
+ "headers": {
200
+ "Accept": "application/hal+json"
201
+ }
202
+ }
203
+ ```
204
+ Pact Broker will respond with:
205
+ ```json
206
+ {
207
+ "status": 404
208
+ }
209
+ ```
117
210
  <a name="a_request_for_the_compatibility_matrix_for_a_pacticipant_that_does_not_exist"></a>
118
211
  Upon receiving **a request for the compatibility matrix for a pacticipant that does not exist** from Pact Broker Client, with
119
212
  ```json
@@ -535,6 +628,36 @@ Pact Broker will respond with:
535
628
  }
536
629
  }
537
630
  ```
631
+ <a name="a_request_for_the_environments_given_an_environment_with_name_test_exists"></a>
632
+ Given **an environment with name test exists**, upon receiving **a request for the environments** from Pact Broker Client, with
633
+ ```json
634
+ {
635
+ "method": "GET",
636
+ "path": "/HAL-REL-PLACEHOLDER-PB-ENVIRONMENTS",
637
+ "headers": {
638
+ "Accept": "application/hal+json"
639
+ }
640
+ }
641
+ ```
642
+ Pact Broker will respond with:
643
+ ```json
644
+ {
645
+ "status": 200,
646
+ "headers": {
647
+ "Content-Type": "application/hal+json;charset=utf-8"
648
+ },
649
+ "body": {
650
+ "_links": {
651
+ "pb:environments": [
652
+ {
653
+ "name": "test",
654
+ "href": "href"
655
+ }
656
+ ]
657
+ }
658
+ }
659
+ }
660
+ ```
538
661
  <a name="a_request_for_the_index_resource"></a>
539
662
  Upon receiving **a request for the index resource** from Pact Broker Client, with
540
663
  ```json
@@ -652,6 +775,36 @@ Pact Broker will respond with:
652
775
  }
653
776
  }
654
777
  ```
778
+ <a name="a_request_for_the_index_resource_given_the_pb:pacticipant-version_and_pb:environments_relations_exist_in_the_index_resource"></a>
779
+ Given **the pb:pacticipant-version and pb:environments relations exist in the index resource**, upon receiving **a request for the index resource** from Pact Broker Client, with
780
+ ```json
781
+ {
782
+ "method": "GET",
783
+ "path": "/",
784
+ "headers": {
785
+ "Accept": "application/hal+json"
786
+ }
787
+ }
788
+ ```
789
+ Pact Broker will respond with:
790
+ ```json
791
+ {
792
+ "status": 200,
793
+ "headers": {
794
+ "Content-Type": "application/hal+json;charset=utf-8"
795
+ },
796
+ "body": {
797
+ "_links": {
798
+ "pb:pacticipant-version": {
799
+ "href": "http://localhost:1234/HAL-REL-PLACEHOLDER-PB-PACTICIPANT-VERSION-{pacticipant}-{version}"
800
+ },
801
+ "pb:environments": {
802
+ "href": "http://localhost:1234/HAL-REL-PLACEHOLDER-PB-ENVIRONMENTS"
803
+ }
804
+ }
805
+ }
806
+ }
807
+ ```
655
808
  <a name="a_request_for_the_index_resource_given_the_pb:pacticipant-version_relation_exists_in_the_index_resource"></a>
656
809
  Given **the pb:pacticipant-version relation exists in the index resource**, upon receiving **a request for the index resource** from Pact Broker Client, with
657
810
  ```json
@@ -1775,6 +1928,33 @@ Pact Broker will respond with:
1775
1928
  }
1776
1929
  }
1777
1930
  ```
1931
+ <a name="a_request_to_record_a_deployment_given_version_5556b8149bf8bac76bc30f50a8a2dd4c22c85f30_of_pacticipant_Foo_exists_with_a_test_environment_available_for_deployment"></a>
1932
+ Given **version 5556b8149bf8bac76bc30f50a8a2dd4c22c85f30 of pacticipant Foo exists with a test environment available for deployment**, upon receiving **a request to record a deployment** from Pact Broker Client, with
1933
+ ```json
1934
+ {
1935
+ "method": "POST",
1936
+ "path": "/HAL-REL-PLACEHOLDER-PB-RECORD-DEPLOYMENT-FOO-5556B8149BF8BAC76BC30F50A8A2DD4C22C85F30-TEST",
1937
+ "headers": {
1938
+ "Content-Type": "application/json",
1939
+ "Accept": "application/hal+json"
1940
+ },
1941
+ "body": {
1942
+ "replacedPreviousDeployedVersion": true
1943
+ }
1944
+ }
1945
+ ```
1946
+ Pact Broker will respond with:
1947
+ ```json
1948
+ {
1949
+ "status": 201,
1950
+ "headers": {
1951
+ "Content-Type": "application/hal+json;charset=utf-8"
1952
+ },
1953
+ "body": {
1954
+ "replacedPreviousDeployedVersion": true
1955
+ }
1956
+ }
1957
+ ```
1778
1958
  <a name="a_request_to_register_the_repository_URL_of_a_pacticipant_given_the_&#39;Pricing_Service&#39;_already_exists_in_the_pact-broker"></a>
1779
1959
  Given **the 'Pricing Service' already exists in the pact-broker**, upon receiving **a request to register the repository URL of a pacticipant** from Pact Broker Client, with
1780
1960
  ```json
@@ -1,2 +1,2 @@
1
1
  require 'pact_broker/client/version'
2
- require 'pact_broker/client/pact_broker_client'
2
+ require 'pact_broker/client/pact_broker_client'
@@ -0,0 +1,13 @@
1
+ class Hash
2
+ def compact
3
+ h = {}
4
+ each do |key, value|
5
+ h[key] = value unless value == nil
6
+ end
7
+ h
8
+ end unless method_defined? :compact
9
+
10
+ def compact!
11
+ reject! {|_key, value| value == nil}
12
+ end unless method_defined? :compact!
13
+ end
@@ -1,4 +1,5 @@
1
1
  require 'pact_broker/client/cli/custom_thor'
2
+ require 'pact_broker/client/hash_refinements'
2
3
  require 'thor/error'
3
4
 
4
5
  module PactBroker
@@ -11,6 +12,8 @@ module PactBroker
11
12
  class VersionCreationError < ::Thor::Error; end
12
13
 
13
14
  class Broker < CustomThor
15
+ using PactBroker::Client::HashRefinements
16
+
14
17
  desc 'can-i-deploy', ''
15
18
  long_desc File.read(File.join(File.dirname(__FILE__), 'can_i_deploy_long_desc.txt'))
16
19
 
@@ -19,16 +22,12 @@ module PactBroker
19
22
  method_option :latest, required: false, aliases: "-l", banner: '[TAG]', desc: "Use the latest pacticipant version. Optionally specify a TAG to use the latest version with the specified tag."
20
23
  method_option :to, required: false, banner: 'TAG', desc: "This is too hard to explain in a short sentence. Look at the examples.", default: nil
21
24
  method_option :to_environment, required: false, banner: 'ENVIRONMENT', desc: "The environment into which the pacticipant(s) are to be deployed", default: nil, hide: true
22
- method_option :broker_base_url, required: true, aliases: "-b", desc: "The base URL of the Pact Broker"
23
- method_option :broker_username, aliases: "-u", desc: "Pact Broker basic auth username"
24
- method_option :broker_password, aliases: "-p", desc: "Pact Broker basic auth password"
25
- method_option :broker_token, aliases: "-k", desc: "Pact Broker bearer token"
26
25
  method_option :output, aliases: "-o", desc: "json or table", default: 'table'
27
- method_option :verbose, aliases: "-v", type: :boolean, default: false, required: false, desc: "Verbose output. Default: false"
28
26
  method_option :retry_while_unknown, banner: 'TIMES', type: :numeric, default: 0, required: false, desc: "The number of times to retry while there is an unknown verification result (ie. the provider verification is likely still running)"
29
27
  method_option :retry_interval, banner: 'SECONDS', type: :numeric, default: 10, required: false, desc: "The time between retries in seconds. Use in conjuction with --retry-while-unknown"
30
28
  # Allow limit to be set manually until https://github.com/pact-foundation/pact_broker-client/issues/53 is fixed
31
29
  method_option :limit, hide: true
30
+ shared_authentication_options
32
31
 
33
32
  def can_i_deploy(*ignored_but_necessary)
34
33
  require 'pact_broker/client/cli/version_selector_options_parser'
@@ -45,17 +44,13 @@ module PactBroker
45
44
 
46
45
  desc 'publish PACT_DIRS_OR_FILES ...', "Publish pacts to a Pact Broker."
47
46
  method_option :consumer_app_version, required: true, aliases: "-a", desc: "The consumer application version"
48
- method_option :broker_base_url, required: true, aliases: "-b", desc: "The base URL of the Pact Broker"
49
- method_option :broker_username, aliases: "-u", desc: "Pact Broker basic auth username"
50
- method_option :broker_password, aliases: "-p", desc: "Pact Broker basic auth password"
51
- method_option :broker_token, aliases: "-k", desc: "Pact Broker bearer token"
52
47
  method_option :branch, aliases: "-h", desc: "Repository branch of the consumer version"
53
48
  method_option :auto_detect_version_properties, hidden: true, type: :boolean, default: false, desc: "Automatically detect the repository branch from known CI environment variables or git CLI."
54
49
  method_option :tag, aliases: "-t", type: :array, banner: "TAG", desc: "Tag name for consumer version. Can be specified multiple times."
55
50
  method_option :tag_with_git_branch, aliases: "-g", type: :boolean, default: false, required: false, desc: "Tag consumer version with the name of the current git branch. Default: false"
56
51
  method_option :build_url, desc: "The build URL that created the pact"
57
52
  method_option :merge, type: :boolean, default: false, require: false, desc: "If a pact already exists for this consumer version and provider, merge the contents. Useful when running Pact tests concurrently on different build nodes."
58
- method_option :verbose, aliases: "-v", type: :boolean, default: false, required: false, desc: "Verbose output. Default: false"
53
+ shared_authentication_options
59
54
 
60
55
  def publish(*pact_files)
61
56
  require 'pact_broker/client/error'
@@ -73,11 +68,7 @@ module PactBroker
73
68
  method_option :tag, aliases: "-t", type: :array, banner: "TAG", desc: "Tag name for pacticipant version. Can be specified multiple times."
74
69
  method_option :auto_create_version, type: :boolean, default: false, desc: "Automatically create the pacticipant version if it does not exist. Default: false"
75
70
  method_option :tag_with_git_branch, aliases: "-g", type: :boolean, default: false, required: false, desc: "Tag pacticipant version with the name of the current git branch. Default: false"
76
- method_option :broker_base_url, required: true, aliases: "-b", desc: "The base URL of the Pact Broker"
77
- method_option :broker_username, aliases: "-u", desc: "Pact Broker basic auth username"
78
- method_option :broker_password, aliases: "-p", desc: "Pact Broker basic auth password"
79
- method_option :broker_token, aliases: "-k", desc: "Pact Broker bearer token"
80
- method_option :verbose, aliases: "-v", type: :boolean, default: false, required: false, desc: "Verbose output. Default: false"
71
+ shared_authentication_options
81
72
 
82
73
  def create_version_tag
83
74
  require 'pact_broker/client/create_tag'
@@ -97,12 +88,8 @@ module PactBroker
97
88
  method_option :pacticipant, required: true, aliases: "-a", desc: "The name of the pacticipant that the version belongs to."
98
89
  method_option :version, required: false, aliases: "-e", desc: "The pacticipant version number."
99
90
  method_option :latest, required: false, aliases: "-l", banner: '[TAG]', desc: "Describe the latest pacticipant version. Optionally specify a TAG to describe the latest version with the specified tag."
100
- method_option :broker_base_url, required: true, aliases: "-b", desc: "The base URL of the Pact Broker"
101
- method_option :broker_username, aliases: "-u", desc: "Pact Broker basic auth username"
102
- method_option :broker_password, aliases: "-p", desc: "Pact Broker basic auth password"
103
- method_option :broker_token, aliases: "-k", desc: "Pact Broker bearer token"
104
91
  method_option :output, aliases: "-o", desc: "json or table or id", default: 'table'
105
- method_option :verbose, aliases: "-v", type: :boolean, default: false, required: false, desc: "Verbose output. Default: false"
92
+ shared_authentication_options
106
93
 
107
94
  desc 'describe-version', 'Describes a pacticipant version. If no version or tag is specified, the latest version is described.'
108
95
  def describe_version
@@ -143,7 +130,7 @@ module PactBroker
143
130
 
144
131
  desc 'test-webhook', 'Test the execution of a webhook'
145
132
  method_option :uuid, type: :string, required: true, desc: "Specify the uuid for the webhook"
146
- shared_authentication_options_for_pact_broker
133
+ shared_authentication_options
147
134
  def test_webhook
148
135
  require 'pact_broker/client/webhooks/test'
149
136
  result = PactBroker::Client::Webhooks::Test.call(options, pact_broker_client_options)
@@ -161,7 +148,7 @@ module PactBroker
161
148
  desc 'create-or-update-pacticipant', 'Create or update pacticipant by name'
162
149
  method_option :name, type: :string, required: true, desc: "Pacticipant name"
163
150
  method_option :repository_url, type: :string, required: false, desc: "The repository URL of the pacticipant"
164
- shared_authentication_options_for_pact_broker
151
+ shared_authentication_options
165
152
  verbose_option
166
153
  def create_or_update_pacticipant(*required_but_ignored)
167
154
  raise ::Thor::RequiredArgumentMissingError, "Pacticipant name cannot be blank" if options.name.strip.size == 0
@@ -172,7 +159,7 @@ module PactBroker
172
159
  end
173
160
 
174
161
  desc 'list-latest-pact-versions', 'List the latest pact for each integration'
175
- shared_authentication_options_for_pact_broker
162
+ shared_authentication_options
176
163
  method_option :output, aliases: "-o", desc: "json or table", default: 'table'
177
164
  def list_latest_pact_versions(*required_but_ignored)
178
165
  require 'pact_broker/client/pacts/list_latest_versions'
@@ -181,6 +168,37 @@ module PactBroker
181
168
  exit(1) unless result.success
182
169
  end
183
170
 
171
+ if ENV.fetch("PACT_BROKER_FEATURES", "").include?("deployments")
172
+
173
+ ignored_and_hidden_potential_options_from_environment_variables
174
+ desc "record-deployment", "Record deployment of a pacticipant version to an environment"
175
+ method_option :pacticipant, required: true, aliases: "-a", desc: "The name of the pacticipant that was deployed."
176
+ method_option :version, required: true, aliases: "-e", desc: "The pacticipant version number that was deployed."
177
+ method_option :environment, required: true, desc: "The name of the environment that the pacticipant version was deployed to."
178
+ method_option :replaced_previous_deployed_version, type: :boolean, default: true, required: false, desc: "Whether or not this deployment replaced the previous deployed version. If it did, the previous deployed version of this pacticipant will be marked as undeployed in the Pact Broker."
179
+ method_option :output, aliases: "-o", desc: "json or text", default: 'text'
180
+ shared_authentication_options
181
+
182
+ def record_deployment
183
+ require 'pact_broker/client/versions/record_deployment'
184
+ params = {
185
+ pacticipant_name: options.pacticipant,
186
+ version_number: options.version,
187
+ environment_name: options.environment,
188
+ replaced_previous_deployed_version: options.replaced_previous_deployed_version,
189
+ output: options.output
190
+ }
191
+ result = PactBroker::Client::Versions::RecordDeployment.call(
192
+ params,
193
+ options.broker_base_url,
194
+ pact_broker_client_options
195
+ )
196
+ $stdout.puts result.message
197
+ exit(1) unless result.success
198
+ end
199
+
200
+ end
201
+
184
202
  ignored_and_hidden_potential_options_from_environment_variables
185
203
  desc 'version', "Show the pact_broker-client gem version"
186
204
  def version
@@ -214,6 +232,7 @@ module PactBroker
214
232
 
215
233
  def publish_pacts pact_files
216
234
  require 'pact_broker/client/publish_pacts'
235
+
217
236
  write_options = options[:merge] ? { write: :merge } : {}
218
237
  consumer_version_params = {
219
238
  number: options.consumer_app_version,
@@ -86,6 +86,14 @@ module PactBroker
86
86
  method_option :broker_token, hide: true
87
87
  end
88
88
 
89
+ def self.shared_authentication_options
90
+ method_option :broker_base_url, required: true, aliases: "-b", desc: "The base URL of the Pact Broker"
91
+ method_option :broker_username, aliases: "-u", desc: "Pact Broker basic auth username"
92
+ method_option :broker_password, aliases: "-p", desc: "Pact Broker basic auth password"
93
+ method_option :broker_token, aliases: "-k", desc: "Pact Broker bearer token"
94
+ method_option :verbose, aliases: "-v", type: :boolean, default: false, required: false, desc: "Verbose output. Default: false"
95
+ end
96
+
89
97
  def self.shared_options_for_webhook_commands
90
98
  method_option :request, banner: "METHOD", aliases: "-X", desc: "Webhook HTTP method", required: true
91
99
  method_option :header, aliases: "-H", type: :array, desc: "Webhook Header"
@@ -93,24 +101,13 @@ module PactBroker
93
101
  method_option :user, aliases: "-u", desc: "Webhook basic auth username and password eg. username:password"
94
102
  method_option :consumer, desc: "Consumer name"
95
103
  method_option :provider, desc: "Provider name"
96
- method_option :broker_base_url, required: true, aliases: "-b", desc: "The base URL of the Pact Broker"
97
- method_option :broker_username, desc: "Pact Broker basic auth username"
98
- method_option :broker_password, aliases: "-p", desc: "Pact Broker basic auth password"
99
- method_option :broker_token, aliases: "-k", desc: "Pact Broker bearer token"
100
104
  method_option :description, desc: "Wwebhook description"
101
105
  method_option :contract_content_changed, type: :boolean, desc: "Trigger this webhook when the pact content changes"
102
106
  method_option :contract_published, type: :boolean, desc: "Trigger this webhook when a pact is published"
103
107
  method_option :provider_verification_published, type: :boolean, desc: "Trigger this webhook when a provider verification result is published"
104
108
  method_option :provider_verification_failed, type: :boolean, desc: "Trigger this webhook when a failed provider verification result is published"
105
109
  method_option :provider_verification_succeeded, type: :boolean, desc: "Trigger this webhook when a successful provider verification result is published"
106
- method_option :verbose, aliases: "-v", type: :boolean, default: false, required: false, desc: "Verbose output. Default: false"
107
- end
108
-
109
- def self.shared_authentication_options_for_pact_broker
110
- method_option :broker_base_url, required: true, aliases: "-b", desc: "The base URL of the Pact Broker"
111
- method_option :broker_username, aliases: "-u", desc: "Pact Broker basic auth username"
112
- method_option :broker_password, aliases: "-p", desc: "Pact Broker basic auth password"
113
- method_option :broker_token, aliases: "-k", desc: "Pact Broker bearer token"
110
+ shared_authentication_options
114
111
  end
115
112
 
116
113
  def self.verbose_option