pact_broker-client 1.39.0 → 1.44.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +21 -0
- data/.gitignore +1 -0
- data/CHANGELOG.md +52 -0
- data/Gemfile +4 -0
- data/README.md +39 -18
- data/doc/pacts/markdown/Pact Broker Client - Pact Broker.md +79 -280
- data/lib/pact_broker/client/backports.rb +9 -0
- data/lib/pact_broker/client/base_command.rb +95 -0
- data/lib/pact_broker/client/can_i_deploy.rb +20 -3
- data/lib/pact_broker/client/cli/broker.rb +20 -75
- data/lib/pact_broker/client/cli/custom_thor.rb +12 -0
- data/lib/pact_broker/client/cli/deployment_commands.rb +74 -0
- data/lib/pact_broker/client/cli/environment_commands.rb +70 -0
- data/lib/pact_broker/client/cli/pacticipant_commands.rb +53 -0
- data/lib/pact_broker/client/cli/record_deployment_long_desc.txt +0 -55
- data/lib/pact_broker/client/cli/version_selector_options_parser.rb +4 -0
- data/lib/pact_broker/client/colorize_notices.rb +31 -0
- data/lib/pact_broker/client/deployments.rb +4 -0
- data/lib/pact_broker/client/deployments/record_deployment.rb +38 -0
- data/lib/pact_broker/client/deployments/record_release.rb +99 -0
- data/lib/pact_broker/client/deployments/record_undeployment.rb +120 -0
- data/lib/pact_broker/client/describe_text_formatter.rb +23 -0
- data/lib/pact_broker/client/environments.rb +6 -0
- data/lib/pact_broker/client/environments/create_environment.rb +31 -0
- data/lib/pact_broker/client/environments/delete_environment.rb +27 -0
- data/lib/pact_broker/client/environments/describe_environment.rb +26 -0
- data/lib/pact_broker/client/environments/environment_command.rb +66 -0
- data/lib/pact_broker/client/environments/list_environments.rb +30 -0
- data/lib/pact_broker/client/environments/text_formatter.rb +30 -0
- data/lib/pact_broker/client/environments/update_environment.rb +31 -0
- data/lib/pact_broker/client/generate_display_name.rb +27 -0
- data/lib/pact_broker/client/hal/entity.rb +14 -4
- data/lib/pact_broker/client/hal/http_client.rb +8 -2
- data/lib/pact_broker/client/hal/link.rb +8 -0
- data/lib/pact_broker/client/hal_client_methods.rb +1 -3
- data/lib/pact_broker/client/matrix.rb +4 -0
- data/lib/pact_broker/client/matrix/abbreviate_version_number.rb +15 -0
- data/lib/pact_broker/client/matrix/resource.rb +26 -1
- data/lib/pact_broker/client/matrix/text_formatter.rb +28 -17
- data/lib/pact_broker/client/pacticipants.rb +6 -0
- data/lib/pact_broker/client/pacticipants/create.rb +24 -34
- data/lib/pact_broker/client/pacticipants/describe.rb +33 -0
- data/lib/pact_broker/client/pacticipants/list.rb +34 -0
- data/lib/pact_broker/client/pacticipants/text_formatter.rb +41 -0
- data/lib/pact_broker/client/publish_pacts.rb +7 -3
- data/lib/pact_broker/client/string_refinements.rb +56 -0
- data/lib/pact_broker/client/version.rb +1 -1
- data/lib/pact_broker/client/versions.rb +4 -1
- data/lib/pact_broker/client/versions/describe.rb +3 -1
- data/lib/pact_broker/client/versions/formatter.rb +3 -1
- data/lib/pact_broker/client/versions/json_formatter.rb +5 -3
- data/lib/pact_broker/client/versions/text_formatter.rb +3 -1
- data/pact-broker-client.gemspec +2 -0
- data/script/approve-all.sh +6 -0
- data/script/publish-pact.sh +24 -6
- data/script/record-deployments-and-releases.sh +10 -0
- data/spec/fixtures/approvals/can_i_deploy_ignore.approved.txt +13 -0
- data/spec/fixtures/approvals/describe_environment.approved.txt +7 -0
- data/spec/fixtures/approvals/describe_pacticipant.approved.txt +2 -0
- data/spec/fixtures/approvals/list_environments.approved.txt +3 -0
- data/spec/integration/describe_environment_spec.rb +31 -0
- data/spec/lib/pact_broker/client/can_i_deploy_spec.rb +47 -5
- data/spec/lib/pact_broker/client/cli/broker_can_i_deploy_spec.rb +5 -5
- data/spec/lib/pact_broker/client/cli/broker_publish_spec.rb +1 -1
- data/spec/lib/pact_broker/client/cli/broker_run_webhook_commands_spec.rb +3 -3
- data/spec/lib/pact_broker/client/cli/version_selector_options_parser_spec.rb +21 -0
- data/spec/lib/pact_broker/client/deployments/record_deployment_spec.rb +204 -0
- data/spec/lib/pact_broker/client/environments/delete_environment_spec.rb +120 -0
- data/spec/lib/pact_broker/client/environments/describe_environment_spec.rb +89 -0
- data/spec/lib/pact_broker/client/environments/update_environment_spec.rb +167 -0
- data/spec/lib/pact_broker/client/generate_display_name_spec.rb +39 -0
- data/spec/lib/pact_broker/client/hal/entity_spec.rb +2 -2
- data/spec/lib/pact_broker/client/pacticipants/create_spec.rb +2 -2
- data/spec/pacts/pact_broker_client-pact_broker.json +88 -287
- data/spec/service_providers/create_environment_spec.rb +78 -0
- data/spec/service_providers/list_environments_spec.rb +77 -0
- data/spec/service_providers/pact_broker_client_matrix_ignore_spec.rb +98 -0
- data/spec/service_providers/pacticipants_create_spec.rb +5 -4
- data/spec/service_providers/publish_pacts_spec.rb +5 -2
- data/spec/service_providers/record_deployment_spec.rb +17 -36
- data/spec/service_providers/record_release_spec.rb +135 -0
- data/spec/spec_helper.rb +15 -2
- data/spec/support/approvals.rb +26 -0
- data/spec/support/shared_context.rb +6 -2
- data/tasks/pact.rake +19 -1
- metadata +93 -7
- data/lib/pact_broker/client/versions/record_deployment.rb +0 -109
- data/lib/pact_broker/client/versions/record_undeployment.rb +0 -102
- data/spec/lib/pact_broker/client/versions/record_deployment_spec.rb +0 -82
data/spec/spec_helper.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'webmock/rspec'
|
2
|
-
|
3
|
-
ENV['PACT_BROKER_FEATURES'] = 'deployments'
|
2
|
+
require 'rspec/its'
|
4
3
|
|
5
4
|
WebMock.disable_net_connect!(allow_localhost: true)
|
6
5
|
|
7
6
|
require "./spec/support/shared_context.rb"
|
7
|
+
require "./spec/support/approvals.rb"
|
8
8
|
|
9
9
|
is_windows = (RbConfig::CONFIG['host_os'] =~ /bccwin|cygwin|djgpp|mingw|mswin|wince/i) != nil
|
10
10
|
is_ci = ENV['CI'] == 'true'
|
@@ -23,6 +23,19 @@ RSpec.configure do | config |
|
|
23
23
|
|
24
24
|
config.filter_run_excluding skip_windows: is_windows, skip_ci: is_ci
|
25
25
|
config.example_status_persistence_file_path = "./spec/examples.txt"
|
26
|
+
|
27
|
+
def capture(stream)
|
28
|
+
begin
|
29
|
+
stream = stream.to_s
|
30
|
+
eval "$#{stream} = StringIO.new"
|
31
|
+
yield
|
32
|
+
result = eval("$#{stream}").string
|
33
|
+
ensure
|
34
|
+
eval("$#{stream} = #{stream.upcase}")
|
35
|
+
end
|
36
|
+
|
37
|
+
result
|
38
|
+
end
|
26
39
|
end
|
27
40
|
|
28
41
|
module Pact
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'approvals/rspec'
|
2
|
+
require 'pact/support'
|
3
|
+
|
4
|
+
Approvals.configure do |c|
|
5
|
+
c.approvals_path = 'spec/fixtures/approvals/'
|
6
|
+
end
|
7
|
+
|
8
|
+
def print_diff(exception)
|
9
|
+
parts = exception.message.split('"')
|
10
|
+
received_file = parts[1]
|
11
|
+
approved_file = parts[3]
|
12
|
+
if File.exist?(received_file) && File.exist?(approved_file) && received_file.end_with?(".json") && approved_file.end_with?(".json")
|
13
|
+
received_hash = JSON.parse(File.read(received_file))
|
14
|
+
approved_hash = JSON.parse(File.read(approved_file))
|
15
|
+
diff = Pact::Matchers.diff(approved_hash, received_hash)
|
16
|
+
puts Pact::Matchers::UnixDiffFormatter.call(diff)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
RSpec.configure do | config |
|
21
|
+
config.after(:each) do | example |
|
22
|
+
if example.exception.is_a?(Approvals::ApprovalError)
|
23
|
+
print_diff(example.exception)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -1,6 +1,11 @@
|
|
1
1
|
require 'pact_broker/client/pact_hash'
|
2
|
-
|
2
|
+
require 'pact_broker/client/hal/http_client'
|
3
3
|
|
4
|
+
shared_context "pact broker" do
|
5
|
+
before do
|
6
|
+
allow_any_instance_of(PactBroker::Client::Hal::HttpClient).to receive(:sleep)
|
7
|
+
allow_any_instance_of(PactBroker::Client::Hal::HttpClient).to receive(:default_max_tries).and_return(1)
|
8
|
+
end
|
4
9
|
let(:pact_hash) { PactBroker::Client::PactHash[consumer: {name: 'Condor'}, provider: {name: 'Pricing Service'}, interactions: []] }
|
5
10
|
let(:consumer_contract) { Pact::ConsumerContract.from_hash pact_hash }
|
6
11
|
let(:pact_json) { pact_hash.to_json }
|
@@ -16,5 +21,4 @@ shared_context "pact broker" do
|
|
16
21
|
let(:put_request_headers) { { 'Content-Type' => 'application/json', 'Accept' => 'application/hal+json'} }
|
17
22
|
let(:post_request_headers) { { 'Content-Type' => 'application/json', 'Accept' => 'application/hal+json'} }
|
18
23
|
let(:get_request_headers) { { 'Accept' => 'application/hal+json'} }
|
19
|
-
|
20
24
|
end
|
data/tasks/pact.rake
CHANGED
@@ -14,5 +14,23 @@ PactBroker::Client::PublicationTask.new(:remote) do | task |
|
|
14
14
|
task.tag = `git rev-parse --abbrev-ref HEAD`.strip
|
15
15
|
task.consumer_version = PactBroker::Client::VERSION
|
16
16
|
task.pact_broker_base_url = "https://test.pact.dius.com.au"
|
17
|
-
task.pact_broker_basic_auth = {username: ENV.fetch('PACT_BROKER_USERNAME'), password: ENV.fetch('PACT_BROKER_PASSWORD')}
|
17
|
+
task.pact_broker_basic_auth = { username: ENV.fetch('PACT_BROKER_USERNAME'), password: ENV.fetch('PACT_BROKER_PASSWORD') }
|
18
|
+
end
|
19
|
+
|
20
|
+
PactBroker::Client::PublicationTask.new(:pactflow) do | task |
|
21
|
+
version = ENV['GITHUB_SHA']
|
22
|
+
tags = ENV['GITHUB_REF'] ? [ENV['GITHUB_REF'].gsub("refs/heads/", "")] : []
|
23
|
+
|
24
|
+
if ENV.fetch('TEST_FEATURE', '') != ''
|
25
|
+
version = "#{version}+#{ENV['TEST_FEATURE']}"
|
26
|
+
tags = ENV['TEST_FEATURE']
|
27
|
+
end
|
28
|
+
|
29
|
+
require 'pact_broker/client/version'
|
30
|
+
task.auto_detect_version_properties = false
|
31
|
+
task.tags = tags
|
32
|
+
task.branch = nil
|
33
|
+
task.consumer_version = version
|
34
|
+
task.pact_broker_base_url = "https://pact-oss.pactflow.io"
|
35
|
+
task.pact_broker_token = ENV['PACT_BROKER_TOKEN']
|
18
36
|
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.
|
4
|
+
version: 1.44.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-
|
11
|
+
date: 2021-06-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -170,6 +170,40 @@ dependencies:
|
|
170
170
|
- - "~>"
|
171
171
|
- !ruby/object:Gem::Version
|
172
172
|
version: '1.16'
|
173
|
+
- !ruby/object:Gem::Dependency
|
174
|
+
name: approvals
|
175
|
+
requirement: !ruby/object:Gem::Requirement
|
176
|
+
requirements:
|
177
|
+
- - ">="
|
178
|
+
- !ruby/object:Gem::Version
|
179
|
+
version: 0.0.24
|
180
|
+
- - "<"
|
181
|
+
- !ruby/object:Gem::Version
|
182
|
+
version: 1.0.0
|
183
|
+
type: :development
|
184
|
+
prerelease: false
|
185
|
+
version_requirements: !ruby/object:Gem::Requirement
|
186
|
+
requirements:
|
187
|
+
- - ">="
|
188
|
+
- !ruby/object:Gem::Version
|
189
|
+
version: 0.0.24
|
190
|
+
- - "<"
|
191
|
+
- !ruby/object:Gem::Version
|
192
|
+
version: 1.0.0
|
193
|
+
- !ruby/object:Gem::Dependency
|
194
|
+
name: rspec-its
|
195
|
+
requirement: !ruby/object:Gem::Requirement
|
196
|
+
requirements:
|
197
|
+
- - "~>"
|
198
|
+
- !ruby/object:Gem::Version
|
199
|
+
version: '1.3'
|
200
|
+
type: :development
|
201
|
+
prerelease: false
|
202
|
+
version_requirements: !ruby/object:Gem::Requirement
|
203
|
+
requirements:
|
204
|
+
- - "~>"
|
205
|
+
- !ruby/object:Gem::Version
|
206
|
+
version: '1.3'
|
173
207
|
description: Client for the Pact Broker. Publish, retrieve and query pacts and verification
|
174
208
|
results.
|
175
209
|
email:
|
@@ -206,17 +240,36 @@ files:
|
|
206
240
|
- lib/pact_broker/client.rb
|
207
241
|
- lib/pact_broker/client/backports.rb
|
208
242
|
- lib/pact_broker/client/base_client.rb
|
243
|
+
- lib/pact_broker/client/base_command.rb
|
209
244
|
- lib/pact_broker/client/can_i_deploy.rb
|
210
245
|
- lib/pact_broker/client/cli/broker.rb
|
211
246
|
- lib/pact_broker/client/cli/can_i_deploy_long_desc.txt
|
212
247
|
- lib/pact_broker/client/cli/create_or_update_webhook_long_desc.txt
|
213
248
|
- lib/pact_broker/client/cli/create_webhook_long_desc.txt
|
214
249
|
- lib/pact_broker/client/cli/custom_thor.rb
|
250
|
+
- lib/pact_broker/client/cli/deployment_commands.rb
|
251
|
+
- lib/pact_broker/client/cli/environment_commands.rb
|
252
|
+
- lib/pact_broker/client/cli/pacticipant_commands.rb
|
215
253
|
- lib/pact_broker/client/cli/record_deployment_long_desc.txt
|
216
254
|
- lib/pact_broker/client/cli/version_selector_options_parser.rb
|
255
|
+
- lib/pact_broker/client/colorize_notices.rb
|
217
256
|
- lib/pact_broker/client/command_result.rb
|
218
257
|
- lib/pact_broker/client/create_tag.rb
|
258
|
+
- lib/pact_broker/client/deployments.rb
|
259
|
+
- lib/pact_broker/client/deployments/record_deployment.rb
|
260
|
+
- lib/pact_broker/client/deployments/record_release.rb
|
261
|
+
- lib/pact_broker/client/deployments/record_undeployment.rb
|
262
|
+
- lib/pact_broker/client/describe_text_formatter.rb
|
263
|
+
- lib/pact_broker/client/environments.rb
|
264
|
+
- lib/pact_broker/client/environments/create_environment.rb
|
265
|
+
- lib/pact_broker/client/environments/delete_environment.rb
|
266
|
+
- lib/pact_broker/client/environments/describe_environment.rb
|
267
|
+
- lib/pact_broker/client/environments/environment_command.rb
|
268
|
+
- lib/pact_broker/client/environments/list_environments.rb
|
269
|
+
- lib/pact_broker/client/environments/text_formatter.rb
|
270
|
+
- lib/pact_broker/client/environments/update_environment.rb
|
219
271
|
- lib/pact_broker/client/error.rb
|
272
|
+
- lib/pact_broker/client/generate_display_name.rb
|
220
273
|
- lib/pact_broker/client/git.rb
|
221
274
|
- lib/pact_broker/client/hal.rb
|
222
275
|
- lib/pact_broker/client/hal/authorization_header_redactor.rb
|
@@ -228,6 +281,7 @@ files:
|
|
228
281
|
- lib/pact_broker/client/hal_client_methods.rb
|
229
282
|
- lib/pact_broker/client/hash_refinements.rb
|
230
283
|
- lib/pact_broker/client/matrix.rb
|
284
|
+
- lib/pact_broker/client/matrix/abbreviate_version_number.rb
|
231
285
|
- lib/pact_broker/client/matrix/formatter.rb
|
232
286
|
- lib/pact_broker/client/matrix/json_formatter.rb
|
233
287
|
- lib/pact_broker/client/matrix/resource.rb
|
@@ -238,11 +292,15 @@ files:
|
|
238
292
|
- lib/pact_broker/client/pact_hash.rb
|
239
293
|
- lib/pact_broker/client/pacticipants.rb
|
240
294
|
- lib/pact_broker/client/pacticipants/create.rb
|
295
|
+
- lib/pact_broker/client/pacticipants/describe.rb
|
296
|
+
- lib/pact_broker/client/pacticipants/list.rb
|
297
|
+
- lib/pact_broker/client/pacticipants/text_formatter.rb
|
241
298
|
- lib/pact_broker/client/pacts.rb
|
242
299
|
- lib/pact_broker/client/pacts/list_latest_versions.rb
|
243
300
|
- lib/pact_broker/client/publish_pacts.rb
|
244
301
|
- lib/pact_broker/client/publish_pacts_the_old_way.rb
|
245
302
|
- lib/pact_broker/client/retry.rb
|
303
|
+
- lib/pact_broker/client/string_refinements.rb
|
246
304
|
- lib/pact_broker/client/tasks.rb
|
247
305
|
- lib/pact_broker/client/tasks/publication_task.rb
|
248
306
|
- lib/pact_broker/client/version.rb
|
@@ -250,23 +308,28 @@ files:
|
|
250
308
|
- lib/pact_broker/client/versions/describe.rb
|
251
309
|
- lib/pact_broker/client/versions/formatter.rb
|
252
310
|
- lib/pact_broker/client/versions/json_formatter.rb
|
253
|
-
- lib/pact_broker/client/versions/record_deployment.rb
|
254
|
-
- lib/pact_broker/client/versions/record_undeployment.rb
|
255
311
|
- lib/pact_broker/client/versions/text_formatter.rb
|
256
312
|
- lib/pact_broker/client/webhooks/create.rb
|
257
313
|
- lib/pact_broker/client/webhooks/test.rb
|
258
314
|
- lib/pact_broker_client.rb
|
259
315
|
- pact-broker-client.gemspec
|
316
|
+
- script/approve-all.sh
|
260
317
|
- script/create-pacticipant.sh
|
261
318
|
- script/generate-cli-usage.sh
|
262
319
|
- script/publish-pact.sh
|
263
320
|
- script/record-deployment.sh
|
321
|
+
- script/record-deployments-and-releases.sh
|
264
322
|
- script/record-undeployment.sh
|
265
323
|
- script/release.sh
|
266
324
|
- script/trigger-release.sh
|
325
|
+
- spec/fixtures/approvals/can_i_deploy_ignore.approved.txt
|
326
|
+
- spec/fixtures/approvals/describe_environment.approved.txt
|
327
|
+
- spec/fixtures/approvals/describe_pacticipant.approved.txt
|
328
|
+
- spec/fixtures/approvals/list_environments.approved.txt
|
267
329
|
- spec/fixtures/foo-bar.json
|
268
330
|
- spec/integration/can_i_deploy_spec.rb
|
269
331
|
- spec/integration/create_version_tag_spec.rb
|
332
|
+
- spec/integration/describe_environment_spec.rb
|
270
333
|
- spec/lib/pact_broker/client/base_client_spec.rb
|
271
334
|
- spec/lib/pact_broker/client/can_i_deploy_spec.rb
|
272
335
|
- spec/lib/pact_broker/client/cli/broker_can_i_deploy_spec.rb
|
@@ -276,6 +339,11 @@ files:
|
|
276
339
|
- spec/lib/pact_broker/client/cli/broker_run_webhook_commands_spec.rb
|
277
340
|
- spec/lib/pact_broker/client/cli/custom_thor_spec.rb
|
278
341
|
- spec/lib/pact_broker/client/cli/version_selector_options_parser_spec.rb
|
342
|
+
- spec/lib/pact_broker/client/deployments/record_deployment_spec.rb
|
343
|
+
- spec/lib/pact_broker/client/environments/delete_environment_spec.rb
|
344
|
+
- spec/lib/pact_broker/client/environments/describe_environment_spec.rb
|
345
|
+
- spec/lib/pact_broker/client/environments/update_environment_spec.rb
|
346
|
+
- spec/lib/pact_broker/client/generate_display_name_spec.rb
|
279
347
|
- spec/lib/pact_broker/client/git_spec.rb
|
280
348
|
- spec/lib/pact_broker/client/hal/authorization_header_redactor_spec.rb
|
281
349
|
- spec/lib/pact_broker/client/hal/entity_spec.rb
|
@@ -292,13 +360,15 @@ files:
|
|
292
360
|
- spec/lib/pact_broker/client/retry_spec.rb
|
293
361
|
- spec/lib/pact_broker/client/tasks/publication_task_spec.rb
|
294
362
|
- spec/lib/pact_broker/client/versions/describe_spec.rb
|
295
|
-
- spec/lib/pact_broker/client/versions/record_deployment_spec.rb
|
296
363
|
- spec/lib/pact_broker/client/versions_spec.rb
|
297
364
|
- spec/lib/pact_broker/client/webhooks/create_spec.rb
|
298
365
|
- spec/pacts/pact_broker_client-pact_broker.json
|
366
|
+
- spec/service_providers/create_environment_spec.rb
|
299
367
|
- spec/service_providers/extra_goodies_spec.rb
|
368
|
+
- spec/service_providers/list_environments_spec.rb
|
300
369
|
- spec/service_providers/list_latest_pact_versions_spec.rb.bak
|
301
370
|
- spec/service_providers/pact_broker_client_create_version_spec.rb
|
371
|
+
- spec/service_providers/pact_broker_client_matrix_ignore_spec.rb
|
302
372
|
- spec/service_providers/pact_broker_client_matrix_spec.rb
|
303
373
|
- spec/service_providers/pact_broker_client_pacticipant_version_spec.rb
|
304
374
|
- spec/service_providers/pact_broker_client_publish_spec.rb
|
@@ -311,8 +381,10 @@ files:
|
|
311
381
|
- spec/service_providers/pacticipants_create_spec.rb
|
312
382
|
- spec/service_providers/publish_pacts_spec.rb
|
313
383
|
- spec/service_providers/record_deployment_spec.rb
|
384
|
+
- spec/service_providers/record_release_spec.rb
|
314
385
|
- spec/service_providers/webhooks_create_spec.rb
|
315
386
|
- spec/spec_helper.rb
|
387
|
+
- spec/support/approvals.rb
|
316
388
|
- spec/support/cli_test_pacts/bar.json
|
317
389
|
- spec/support/cli_test_pacts/foo.json
|
318
390
|
- spec/support/latest_pacts_for_provider.json
|
@@ -344,14 +416,19 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
344
416
|
- !ruby/object:Gem::Version
|
345
417
|
version: '0'
|
346
418
|
requirements: []
|
347
|
-
rubygems_version: 3.2.
|
419
|
+
rubygems_version: 3.2.19
|
348
420
|
signing_key:
|
349
421
|
specification_version: 4
|
350
422
|
summary: See description
|
351
423
|
test_files:
|
424
|
+
- spec/fixtures/approvals/can_i_deploy_ignore.approved.txt
|
425
|
+
- spec/fixtures/approvals/describe_environment.approved.txt
|
426
|
+
- spec/fixtures/approvals/describe_pacticipant.approved.txt
|
427
|
+
- spec/fixtures/approvals/list_environments.approved.txt
|
352
428
|
- spec/fixtures/foo-bar.json
|
353
429
|
- spec/integration/can_i_deploy_spec.rb
|
354
430
|
- spec/integration/create_version_tag_spec.rb
|
431
|
+
- spec/integration/describe_environment_spec.rb
|
355
432
|
- spec/lib/pact_broker/client/base_client_spec.rb
|
356
433
|
- spec/lib/pact_broker/client/can_i_deploy_spec.rb
|
357
434
|
- spec/lib/pact_broker/client/cli/broker_can_i_deploy_spec.rb
|
@@ -361,6 +438,11 @@ test_files:
|
|
361
438
|
- spec/lib/pact_broker/client/cli/broker_run_webhook_commands_spec.rb
|
362
439
|
- spec/lib/pact_broker/client/cli/custom_thor_spec.rb
|
363
440
|
- spec/lib/pact_broker/client/cli/version_selector_options_parser_spec.rb
|
441
|
+
- spec/lib/pact_broker/client/deployments/record_deployment_spec.rb
|
442
|
+
- spec/lib/pact_broker/client/environments/delete_environment_spec.rb
|
443
|
+
- spec/lib/pact_broker/client/environments/describe_environment_spec.rb
|
444
|
+
- spec/lib/pact_broker/client/environments/update_environment_spec.rb
|
445
|
+
- spec/lib/pact_broker/client/generate_display_name_spec.rb
|
364
446
|
- spec/lib/pact_broker/client/git_spec.rb
|
365
447
|
- spec/lib/pact_broker/client/hal/authorization_header_redactor_spec.rb
|
366
448
|
- spec/lib/pact_broker/client/hal/entity_spec.rb
|
@@ -377,13 +459,15 @@ test_files:
|
|
377
459
|
- spec/lib/pact_broker/client/retry_spec.rb
|
378
460
|
- spec/lib/pact_broker/client/tasks/publication_task_spec.rb
|
379
461
|
- spec/lib/pact_broker/client/versions/describe_spec.rb
|
380
|
-
- spec/lib/pact_broker/client/versions/record_deployment_spec.rb
|
381
462
|
- spec/lib/pact_broker/client/versions_spec.rb
|
382
463
|
- spec/lib/pact_broker/client/webhooks/create_spec.rb
|
383
464
|
- spec/pacts/pact_broker_client-pact_broker.json
|
465
|
+
- spec/service_providers/create_environment_spec.rb
|
384
466
|
- spec/service_providers/extra_goodies_spec.rb
|
467
|
+
- spec/service_providers/list_environments_spec.rb
|
385
468
|
- spec/service_providers/list_latest_pact_versions_spec.rb.bak
|
386
469
|
- spec/service_providers/pact_broker_client_create_version_spec.rb
|
470
|
+
- spec/service_providers/pact_broker_client_matrix_ignore_spec.rb
|
387
471
|
- spec/service_providers/pact_broker_client_matrix_spec.rb
|
388
472
|
- spec/service_providers/pact_broker_client_pacticipant_version_spec.rb
|
389
473
|
- spec/service_providers/pact_broker_client_publish_spec.rb
|
@@ -396,8 +480,10 @@ test_files:
|
|
396
480
|
- spec/service_providers/pacticipants_create_spec.rb
|
397
481
|
- spec/service_providers/publish_pacts_spec.rb
|
398
482
|
- spec/service_providers/record_deployment_spec.rb
|
483
|
+
- spec/service_providers/record_release_spec.rb
|
399
484
|
- spec/service_providers/webhooks_create_spec.rb
|
400
485
|
- spec/spec_helper.rb
|
486
|
+
- spec/support/approvals.rb
|
401
487
|
- spec/support/cli_test_pacts/bar.json
|
402
488
|
- spec/support/cli_test_pacts/foo.json
|
403
489
|
- spec/support/latest_pacts_for_provider.json
|
@@ -1,109 +0,0 @@
|
|
1
|
-
require 'pact_broker/client/hal_client_methods'
|
2
|
-
require 'pact_broker/client/error'
|
3
|
-
require 'pact_broker/client/command_result'
|
4
|
-
|
5
|
-
module PactBroker
|
6
|
-
module Client
|
7
|
-
class Versions
|
8
|
-
class RecordDeployment
|
9
|
-
include PactBroker::Client::HalClientMethods
|
10
|
-
|
11
|
-
NOT_SUPPORTED_MESSAGE = "This version of the Pact Broker does not support recording deployments. Please upgrade to version 2.80.0 or later."
|
12
|
-
|
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
|
19
|
-
@pacticipant_name = params.fetch(:pacticipant_name)
|
20
|
-
@version_number = params.fetch(:version_number)
|
21
|
-
@environment_name = params.fetch(:environment_name)
|
22
|
-
@target = params.fetch(:target)
|
23
|
-
@output = params.fetch(:output)
|
24
|
-
@pact_broker_client_options = pact_broker_client_options
|
25
|
-
end
|
26
|
-
|
27
|
-
def call
|
28
|
-
check_if_command_supported
|
29
|
-
record_deployment
|
30
|
-
|
31
|
-
PactBroker::Client::CommandResult.new(true, result_message)
|
32
|
-
rescue PactBroker::Client::Error => e
|
33
|
-
PactBroker::Client::CommandResult.new(false, e.message)
|
34
|
-
end
|
35
|
-
|
36
|
-
private
|
37
|
-
|
38
|
-
attr_reader :pact_broker_base_url, :pact_broker_client_options
|
39
|
-
attr_reader :pacticipant_name, :version_number, :environment_name, :target, :output
|
40
|
-
attr_reader :deployed_version_resource
|
41
|
-
|
42
|
-
def check_environment_exists
|
43
|
-
index_resource
|
44
|
-
._link!("pb:environments")
|
45
|
-
.get!
|
46
|
-
._links("pb:environments")
|
47
|
-
.find!(environment_name, "No environment found with name '#{environment_name}'")
|
48
|
-
end
|
49
|
-
|
50
|
-
def record_deployment
|
51
|
-
@deployed_version_resource =
|
52
|
-
get_record_deployment_relation
|
53
|
-
.post(record_deployment_request_body)
|
54
|
-
.assert_success!
|
55
|
-
end
|
56
|
-
|
57
|
-
def get_record_deployment_relation
|
58
|
-
record_deployment_links = get_pacticipant_version._links!("pb:record-deployment")
|
59
|
-
link_for_environment = record_deployment_links.find(environment_name)
|
60
|
-
if link_for_environment
|
61
|
-
link_for_environment
|
62
|
-
else
|
63
|
-
check_environment_exists
|
64
|
-
# Force the exception to be raised
|
65
|
-
record_deployment_links.find!(environment_name, "Environment '#{environment_name}' is not an available option for recording a deployment of #{pacticipant_name}.")
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
def get_pacticipant_version
|
70
|
-
index_resource
|
71
|
-
._link!("pb:pacticipant-version")
|
72
|
-
.expand(pacticipant: pacticipant_name, version: version_number)
|
73
|
-
.get
|
74
|
-
.assert_success!(404 => "#{pacticipant_name} version #{version_number} not found")
|
75
|
-
end
|
76
|
-
|
77
|
-
def record_deployment_request_body
|
78
|
-
{ replacedPreviousDeployedVersion: target }
|
79
|
-
end
|
80
|
-
|
81
|
-
def result_message
|
82
|
-
if output == "text"
|
83
|
-
message = "Recorded deployment of #{pacticipant_name} version #{version_number} to #{environment_name} in #{pact_broker_name}."
|
84
|
-
suffix = target ? " Marked previous deployed version as undeployed." : ""
|
85
|
-
message + suffix
|
86
|
-
elsif output == "json"
|
87
|
-
deployed_version_resource.response.raw_body
|
88
|
-
else
|
89
|
-
""
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
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
|
-
def check_if_command_supported
|
102
|
-
unless index_resource.can?("pb:environments")
|
103
|
-
raise PactBroker::Client::Error.new(NOT_SUPPORTED_MESSAGE)
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|