pact_broker-client 1.56.0 → 1.57.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/README.md +4 -2
- data/lib/pact_broker/client/cli/matrix_commands.rb +3 -2
- data/lib/pact_broker/client/cli/version_selector_options_parser.rb +4 -0
- data/lib/pact_broker/client/deployments/record_release.rb +5 -1
- data/lib/pact_broker/client/deployments/record_undeployment.rb +1 -1
- data/lib/pact_broker/client/environments/environment_command.rb +6 -1
- data/lib/pact_broker/client/hal/entity.rb +2 -2
- data/lib/pact_broker/client/hal/http_client.rb +4 -0
- data/lib/pact_broker/client/hal/link.rb +7 -2
- data/lib/pact_broker/client/publish_pacts.rb +5 -1
- data/lib/pact_broker/client/version.rb +1 -1
- data/script/can-i-deploy.sh +5 -0
- data/script/record-deployments-and-releases.sh +3 -3
- data/spec/lib/pact_broker/client/cli/version_selector_options_parser_spec.rb +6 -0
- data/spec/lib/pact_broker/client/deployments/record_deployment_spec.rb +12 -1
- data/spec/lib/pact_broker/client/deployments/record_undeployment_spec.rb +1 -1
- data/spec/lib/pact_broker/client/hal/link_spec.rb +15 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2d919435a18e3fdcfa55f3c4e75194c950e027924b2fb274a88bb78ce04035be
|
4
|
+
data.tar.gz: b80790889dde8ee96a98d48b8558608ca0f240da15ece8d57cdc15d646317d42
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c36cfba633f104712099c648e8ef1ccf58dfd1e3025fc44719cdaf6b3e4b47af0ba27af0da7d01074ffc8f6c01cbc4e3e0195b5d95f18e5e960bbac038c6370
|
7
|
+
data.tar.gz: 33526cff8acc17cd129b2521127f4abc3f73eac56b4f1c3e832fe0fb3583bdbe3a1917ae2ac9ec8796414584ad97777e89f163c5732ac5f5f4a879a6c4955be3
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
<a name="v1.57.0"></a>
|
2
|
+
### v1.57.0 (2021-11-05)
|
3
|
+
|
4
|
+
#### Features
|
5
|
+
|
6
|
+
* support the --branch option in the version selectors for can-i-deploy ([dba8ec4](/../../commit/dba8ec4))
|
7
|
+
* show more helpful error message if pb:environments not available for pactflow ([1bf38e3](/../../commit/1bf38e3))
|
8
|
+
* print out notices if returned from publish pacts request ([86caf7e](/../../commit/86caf7e))
|
9
|
+
|
1
10
|
<a name="v1.56.0"></a>
|
2
11
|
### v1.56.0 (2021-10-06)
|
3
12
|
|
data/README.md
CHANGED
@@ -837,11 +837,13 @@ require 'pact_broker/client/tasks'
|
|
837
837
|
|
838
838
|
PactBroker::Client::PublicationTask.new do | task |
|
839
839
|
require 'my_consumer/version'
|
840
|
-
task.consumer_version =
|
840
|
+
task.consumer_version = ENV["GIT_COMMIT"]
|
841
841
|
task.pattern = 'custom/path/to/pacts/*.json' # optional, default value is 'spec/pacts/*.json'
|
842
842
|
task.pact_broker_base_url = "http://pact-broker"
|
843
|
-
task.
|
843
|
+
task.branch = ENV["GIT_BRANCH"] # Optional but STRONGLY RECOMMENDED.
|
844
|
+
task.tag_with_git_branch = true|false # Superseeded by the `branch` property
|
844
845
|
task.tags = ["dev"] # optional
|
846
|
+
task.build_url = ENV["CI_BUILD_URL"]
|
845
847
|
task.pact_broker_basic_auth = { username: 'basic_auth_user', password: 'basic_auth_pass'} # optional
|
846
848
|
task.pact_broker_token = "1234abcd" # Bearer token
|
847
849
|
task.write_method = :merge # optional, this will merge the published pact into an existing pact rather than overwriting it if one exists. Not recommended, as it makes a mulch of the workflow on the broker.
|
@@ -13,6 +13,7 @@ module PactBroker
|
|
13
13
|
method_option :ignore, required: false, desc: "The pacticipant name to ignore. Use once for each pacticipant being ignored. A specific version can be ignored by also specifying a --version after the pacticipant name option."
|
14
14
|
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."
|
15
15
|
method_option :to_environment, required: false, banner: "ENVIRONMENT", desc: "The environment into which the pacticipant(s) are to be deployed", default: nil
|
16
|
+
method_option :branch, required: false, desc: "The branch of the version for which you want to check the verification results", default: nil
|
16
17
|
method_option :to, required: false, banner: "TAG", desc: "The tag that represents the branch or environment of the integrated applications for which you want to check the verification result status.", default: nil
|
17
18
|
method_option :output, aliases: "-o", desc: "json or table", default: "table"
|
18
19
|
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)"
|
@@ -77,8 +78,8 @@ module PactBroker
|
|
77
78
|
end
|
78
79
|
|
79
80
|
def validate_can_i_deploy_selectors selectors
|
80
|
-
pacticipants_without_versions = selectors.select{ |s| s[:version].nil? && s[:latest].nil? && s[:tag].nil? }.collect{ |s| s[:pacticipant] }
|
81
|
-
raise ::Thor::RequiredArgumentMissingError, "The version must be specified using `--version VERSION`, `--latest`, `--latest TAG`, or `--all TAG` for pacticipant #{pacticipants_without_versions.join(", ")}" if pacticipants_without_versions.any?
|
81
|
+
pacticipants_without_versions = selectors.select{ |s| s[:version].nil? && s[:latest].nil? && s[:tag].nil? && s[:branch].nil? }.collect{ |s| s[:pacticipant] }
|
82
|
+
raise ::Thor::RequiredArgumentMissingError, "The version must be specified using `--version VERSION`, `--branch BRANCH` `--latest`, `--latest TAG`, or `--all TAG` for pacticipant #{pacticipants_without_versions.join(", ")}" if pacticipants_without_versions.any?
|
82
83
|
end
|
83
84
|
end
|
84
85
|
end
|
@@ -31,6 +31,10 @@ module PactBroker
|
|
31
31
|
when "--latest", "-l"
|
32
32
|
selectors << { pacticipant: nil } if selectors.empty?
|
33
33
|
selectors.last[:tag] = word
|
34
|
+
when "--branch"
|
35
|
+
selectors << { pacticipant: nil } if selectors.empty?
|
36
|
+
selectors.last[:branch] = word
|
37
|
+
selectors.last[:latest] = true
|
34
38
|
when "--all"
|
35
39
|
selectors << { pacticipant: nil } if selectors.empty?
|
36
40
|
selectors.last[:tag] = word
|
@@ -30,7 +30,11 @@ module PactBroker
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def not_supported_message
|
33
|
-
|
33
|
+
if is_pactflow?
|
34
|
+
"This version of Pactflow does not support recording #{action}s, or you do not have the required permission to read environments. Please upgrade to the latest version if using Pactflow On-Premises, and ensure the user has the environment read permission."
|
35
|
+
else
|
36
|
+
"This version of the Pact Broker does not support recording #{action}s. Please upgrade to version 2.80.0 or later."
|
37
|
+
end
|
34
38
|
end
|
35
39
|
|
36
40
|
def environment_exists?
|
@@ -108,7 +108,7 @@ module PactBroker
|
|
108
108
|
potential_application_instances = currently_deployed_version_entities_for_pacticipant.collect{|e| e.applicationInstance || e.target }
|
109
109
|
|
110
110
|
if application_instance
|
111
|
-
omit_text = potential_application_instances.include?(nil) ? "omit the application instance
|
111
|
+
omit_text = potential_application_instances.include?(nil) ? "omit the application instance" : nil
|
112
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
113
|
"#{pacticipant_name} is not currently deployed to application instance '#{application_instance}' in #{environment_name} environment. Please #{[omit_text, specify_text].compact.join(" or ")}."
|
114
114
|
else
|
@@ -5,6 +5,7 @@ module PactBroker
|
|
5
5
|
module Environments
|
6
6
|
class EnvironmentCommand < PactBroker::Client::BaseCommand
|
7
7
|
NOT_SUPPORTED_MESSAGE = "This version of the Pact Broker does not support environments. Please upgrade to version 2.80.0 or later."
|
8
|
+
PACTFLOW_NOT_SUPPORTED_MESSAGE = "This version of Pactflow does not support environments or you do not have the required permission to read them. Please upgrade to the latest version if using Pactflow On-Premises and ensure the user has the environment read permission."
|
8
9
|
|
9
10
|
private
|
10
11
|
|
@@ -57,7 +58,11 @@ module PactBroker
|
|
57
58
|
|
58
59
|
def check_if_command_supported
|
59
60
|
unless index_resource.can?("pb:environments")
|
60
|
-
|
61
|
+
if is_pactflow?
|
62
|
+
raise PactBroker::Client::Error.new(PACTFLOW_NOT_SUPPORTED_MESSAGE)
|
63
|
+
else
|
64
|
+
raise PactBroker::Client::Error.new(NOT_SUPPORTED_MESSAGE)
|
65
|
+
end
|
61
66
|
end
|
62
67
|
end
|
63
68
|
end
|
@@ -141,9 +141,9 @@ module PactBroker
|
|
141
141
|
end
|
142
142
|
|
143
143
|
def method_missing(method_name, *args, &block)
|
144
|
-
if @data.key?(method_name.to_s)
|
144
|
+
if @data.respond_to?(:key?) && @data.key?(method_name.to_s)
|
145
145
|
@data[method_name.to_s]
|
146
|
-
elsif @links.key?(method_name)
|
146
|
+
elsif @links.respond_to?(:key?) && @links.key?(method_name)
|
147
147
|
Link.new(@links[method_name], @client).run(*args)
|
148
148
|
else
|
149
149
|
nil
|
@@ -86,11 +86,16 @@ module PactBroker
|
|
86
86
|
private
|
87
87
|
|
88
88
|
def wrap_response(href, http_response)
|
89
|
-
require
|
89
|
+
require "pact_broker/client/hal/entity" # avoid circular reference
|
90
90
|
if http_response.success?
|
91
91
|
Entity.new(href, http_response.body, @http_client, http_response)
|
92
92
|
else
|
93
|
-
|
93
|
+
body = begin
|
94
|
+
http_response.header("Content-Type") && http_response.header("Content-Type").include?("json") ? http_response.body : http_response.raw_body
|
95
|
+
rescue
|
96
|
+
http_response.raw_body
|
97
|
+
end
|
98
|
+
ErrorEntity.new(href, body, @http_client, http_response)
|
94
99
|
end
|
95
100
|
end
|
96
101
|
|
@@ -86,7 +86,11 @@ module PactBroker
|
|
86
86
|
"Successfully published pacts"
|
87
87
|
end
|
88
88
|
else
|
89
|
-
|
89
|
+
if response_entity.notices
|
90
|
+
PactBroker::Client::ColorizeNotices.call(response_entity.notices.collect{ |n| OpenStruct.new(n) } )
|
91
|
+
else
|
92
|
+
::Term::ANSIColor.red(response_entity.response.raw_body)
|
93
|
+
end
|
90
94
|
end
|
91
95
|
end.join("\n")
|
92
96
|
end
|
@@ -6,12 +6,12 @@ bundle exec bin/pact-broker can-i-deploy --pacticipant Foo --version 2 --to-envi
|
|
6
6
|
|
7
7
|
bundle exec bin/pact-broker record-deployment --pacticipant Foo --version 2 --environment test
|
8
8
|
bundle exec bin/pact-broker record-deployment --pacticipant Foo --version 2 --environment test --target customer-1
|
9
|
-
bundle exec bin/pact-broker record-deployment --pacticipant Foo --version 2 --environment test --
|
9
|
+
bundle exec bin/pact-broker record-deployment --pacticipant Foo --version 2 --environment test --application-instance customer-1
|
10
10
|
|
11
|
-
bundle exec bin/pact-broker record-undeployment --pacticipant Foo --environment test --
|
11
|
+
bundle exec bin/pact-broker record-undeployment --pacticipant Foo --environment test --application-instance customer-2
|
12
12
|
bundle exec bin/pact-broker record-undeployment --pacticipant Foo --environment test
|
13
13
|
bundle exec bin/pact-broker record-undeployment --pacticipant Foo --environment test
|
14
|
-
bundle exec bin/pact-broker record-undeployment --pacticipant Foo --environment test --
|
14
|
+
bundle exec bin/pact-broker record-undeployment --pacticipant Foo --environment test --application-instance customer-1
|
15
15
|
|
16
16
|
bundle exec bin/pact-broker record-release --pacticipant Foo --version 2 --environment test
|
17
17
|
bundle exec bin/pact-broker record-support-ended --pacticipant Foo --version 2 --environment test
|
@@ -69,6 +69,12 @@ module PactBroker
|
|
69
69
|
],[
|
70
70
|
["--version", "2"],
|
71
71
|
[{ pacticipant: nil, version: "2" }]
|
72
|
+
],[
|
73
|
+
["--pacticipant", "Foo", "--branch", "main"],
|
74
|
+
[{ pacticipant: "Foo", branch: "main", latest: true }]
|
75
|
+
],[
|
76
|
+
["--branch", "main"],
|
77
|
+
[{ pacticipant: nil, branch: "main", latest: true }]
|
72
78
|
]
|
73
79
|
]
|
74
80
|
|
@@ -44,8 +44,9 @@ module PactBroker
|
|
44
44
|
let(:record_deployment_body_hash) do
|
45
45
|
{ "some" => "response" }
|
46
46
|
end
|
47
|
+
let(:index_headers) { { "Content-Type" => "application/hal+json" } }
|
47
48
|
let!(:index_request) do
|
48
|
-
stub_request(:get, broker_base_url).to_return(status: 200, body: index_body_hash.to_json, headers:
|
49
|
+
stub_request(:get, broker_base_url).to_return(status: 200, body: index_body_hash.to_json, headers: index_headers )
|
49
50
|
end
|
50
51
|
let!(:version_request) do
|
51
52
|
stub_request(:get, broker_base_url + "/pacticipants/Foo/versions/1").to_return(status: 200, body: version_body_hash.to_json, headers: { "Content-Type" => "application/hal+json" } )
|
@@ -89,10 +90,20 @@ module PactBroker
|
|
89
90
|
"_links" => {}
|
90
91
|
}
|
91
92
|
end
|
93
|
+
|
92
94
|
it "returns an error response" do
|
93
95
|
expect(subject.success).to be false
|
94
96
|
expect(subject.message).to include "does not support"
|
95
97
|
end
|
98
|
+
|
99
|
+
context "when the server is Pactflow" do
|
100
|
+
let(:index_headers) { { "Content-Type" => "application/hal+json", "Pactflow-Something" => "foo" } }
|
101
|
+
|
102
|
+
it "returns an error response" do
|
103
|
+
expect(subject.message).to include "permission"
|
104
|
+
expect(subject.message).to include "does not support"
|
105
|
+
end
|
106
|
+
end
|
96
107
|
end
|
97
108
|
|
98
109
|
context "when the specified version does not exist" do
|
@@ -174,7 +174,7 @@ module PactBroker
|
|
174
174
|
|
175
175
|
context "when a target is provided and there is no deployed version with a matching target" do
|
176
176
|
let(:application_instance) { "wrong" }
|
177
|
-
let(:expected_message) { "Foo is not currently deployed to application instance 'wrong' in test environment. Please omit the application instance
|
177
|
+
let(:expected_message) { "Foo is not currently deployed to application instance 'wrong' in test environment. Please omit the application instance or specify one of the following application instances to record the undeployment from: customer-1." }
|
178
178
|
|
179
179
|
its(:success) { is_expected.to be false }
|
180
180
|
its(:message) { is_expected.to include expected_message }
|
@@ -5,6 +5,10 @@ require 'pact_broker/client/hal/http_client'
|
|
5
5
|
module PactBroker::Client
|
6
6
|
module Hal
|
7
7
|
describe Link do
|
8
|
+
before do
|
9
|
+
allow(response).to receive(:header).with("Content-Type").and_return(content_type)
|
10
|
+
end
|
11
|
+
|
8
12
|
let(:http_client) do
|
9
13
|
instance_double('PactBroker::Client::Hal::HttpClient', post: response)
|
10
14
|
end
|
@@ -33,6 +37,8 @@ module PactBroker::Client
|
|
33
37
|
}
|
34
38
|
end
|
35
39
|
|
40
|
+
let(:content_type) { nil }
|
41
|
+
|
36
42
|
subject { Link.new(attrs, http_client) }
|
37
43
|
|
38
44
|
before do
|
@@ -67,6 +73,15 @@ module PactBroker::Client
|
|
67
73
|
expect(PactBroker::Client::Hal::ErrorEntity).to receive(:new).with("http://foo/{bar}", response_body.to_json, http_client, response)
|
68
74
|
do_run
|
69
75
|
end
|
76
|
+
|
77
|
+
context "when a JSON error is returned" do
|
78
|
+
let(:content_type) { "application/json" }
|
79
|
+
|
80
|
+
it "parses the response body" do
|
81
|
+
expect(PactBroker::Client::Hal::ErrorEntity).to receive(:new).with("http://foo/{bar}", response_body, http_client, response)
|
82
|
+
do_run
|
83
|
+
end
|
84
|
+
end
|
70
85
|
end
|
71
86
|
end
|
72
87
|
|
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.57.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-11-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -319,6 +319,7 @@ files:
|
|
319
319
|
- lib/pact_broker_client.rb
|
320
320
|
- pact-broker-client.gemspec
|
321
321
|
- script/approve-all.sh
|
322
|
+
- script/can-i-deploy.sh
|
322
323
|
- script/create-pacticipant.sh
|
323
324
|
- script/publish-pact.sh
|
324
325
|
- script/record-deployment.sh
|
@@ -430,7 +431,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
430
431
|
- !ruby/object:Gem::Version
|
431
432
|
version: '0'
|
432
433
|
requirements: []
|
433
|
-
rubygems_version: 3.2.
|
434
|
+
rubygems_version: 3.2.30
|
434
435
|
signing_key:
|
435
436
|
specification_version: 4
|
436
437
|
summary: See description
|