pact_broker 2.107.1 → 2.109.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 +68 -0
- data/Gemfile +5 -6
- data/README.md +1 -0
- data/db/migrations/20230615_add_integrations_contract_data_updated_at.rb +13 -0
- data/db/migrations/20230616_set_integrations_contract_data_updated_at.rb +11 -0
- data/db/migrations/20231002_add_version_id_index_to_released_version.rb +21 -0
- data/db/migrations/20231003_add_version_id_index_to_deployed_version.rb +21 -0
- data/docs/CONFIGURATION.md +10 -0
- data/lib/pact_broker/api/contracts/base_contract.rb +2 -1
- data/lib/pact_broker/api/contracts/dry_validation_errors_formatter.rb +2 -0
- data/lib/pact_broker/api/contracts/pagination_query_params_schema.rb +19 -0
- data/lib/pact_broker/api/contracts/publish_contracts_contract_contract.rb +29 -18
- data/lib/pact_broker/api/decorators/base_decorator.rb +40 -1
- data/lib/pact_broker/api/decorators/branch_decorator.rb +35 -0
- data/lib/pact_broker/api/decorators/branch_version_decorator.rb +16 -0
- data/lib/pact_broker/api/decorators/configuration.rb +19 -0
- data/lib/pact_broker/api/decorators/custom_error_problem_json_decorator.rb +1 -1
- data/lib/pact_broker/api/decorators/decorator_context_creator.rb +47 -2
- data/lib/pact_broker/api/decorators/deployed_version_decorator.rb +2 -1
- data/lib/pact_broker/api/decorators/deployed_versions_decorator.rb +2 -2
- data/lib/pact_broker/api/decorators/dry_validation_errors_decorator.rb +32 -0
- data/lib/pact_broker/api/decorators/dry_validation_errors_problem_json_decorator.rb +24 -0
- data/lib/pact_broker/api/decorators/embedded_branch_version_decorator.rb +2 -2
- data/lib/pact_broker/api/decorators/embedded_deployed_version_decorator.rb +30 -0
- data/lib/pact_broker/api/decorators/embedded_error_problem_json_decorator.rb +84 -0
- data/lib/pact_broker/api/decorators/embedded_released_version_decorator.rb +27 -0
- data/lib/pact_broker/api/decorators/embedded_version_decorator.rb +0 -3
- data/lib/pact_broker/api/decorators/error_decorator.rb +30 -0
- data/lib/pact_broker/api/decorators/extended_pact_decorator.rb +6 -1
- data/lib/pact_broker/api/decorators/integration_decorator.rb +3 -2
- data/lib/pact_broker/api/decorators/integrations_decorator.rb +3 -0
- data/lib/pact_broker/api/decorators/notices_decorator.rb +11 -0
- data/lib/pact_broker/api/decorators/pact_pacticipant_decorator.rb +1 -5
- data/lib/pact_broker/api/decorators/pact_versions_decorator.rb +0 -1
- data/lib/pact_broker/api/decorators/pact_webhooks_status_decorator.rb +0 -1
- data/lib/pact_broker/api/decorators/pacticipant_branches_decorator.rb +32 -0
- data/lib/pact_broker/api/decorators/pacticipant_decorator.rb +11 -1
- data/lib/pact_broker/api/decorators/{pacticipant_collection_decorator.rb → pacticipants_decorator.rb} +8 -4
- data/lib/pact_broker/api/decorators/pagination_links.rb +2 -2
- data/lib/pact_broker/api/decorators/publish_contract_decorator.rb +6 -1
- data/lib/pact_broker/api/decorators/released_versions_decorator.rb +2 -2
- data/lib/pact_broker/api/decorators/runtime_error_problem_json_decorator.rb +2 -2
- data/lib/pact_broker/api/decorators/validation_errors_decorator.rb +30 -0
- data/lib/pact_broker/api/decorators/validation_errors_problem_json_decorator.rb +4 -6
- data/lib/pact_broker/api/decorators/version_decorator.rb +5 -3
- data/lib/pact_broker/api/decorators/versions_decorator.rb +24 -14
- data/lib/pact_broker/api/decorators/webhook_decorator.rb +1 -1
- data/lib/pact_broker/api/decorators/webhook_execution_result_decorator.rb +2 -0
- data/lib/pact_broker/api/middleware/configuration.rb +2 -0
- data/lib/pact_broker/api/pact_broker_urls.rb +18 -2
- data/lib/pact_broker/api/resources/after_reply.rb +15 -0
- data/lib/pact_broker/api/resources/all_webhooks.rb +3 -3
- data/lib/pact_broker/api/resources/badge_methods.rb +2 -1
- data/lib/pact_broker/api/resources/base_resource.rb +6 -4
- data/lib/pact_broker/api/resources/branch.rb +40 -0
- data/lib/pact_broker/api/resources/branch_versions.rb +59 -0
- data/lib/pact_broker/api/resources/can_i_deploy_pacticipant_version_by_branch_to_environment_badge.rb +1 -1
- data/lib/pact_broker/api/resources/currently_deployed_versions_for_environment.rb +1 -1
- data/lib/pact_broker/api/resources/currently_supported_versions_for_environment.rb +1 -1
- data/lib/pact_broker/api/resources/dashboard.rb +10 -0
- data/lib/pact_broker/api/resources/deployed_versions_for_version_and_environment.rb +1 -1
- data/lib/pact_broker/api/resources/environment.rb +4 -0
- data/lib/pact_broker/api/resources/environments.rb +1 -1
- data/lib/pact_broker/api/resources/error_handler.rb +18 -52
- data/lib/pact_broker/api/resources/error_handling_methods.rb +40 -14
- data/lib/pact_broker/api/resources/error_response_generator.rb +23 -6
- data/lib/pact_broker/api/resources/event_methods.rb +15 -0
- data/lib/pact_broker/api/resources/filter_methods.rb +15 -0
- data/lib/pact_broker/api/resources/group.rb +11 -2
- data/lib/pact_broker/api/resources/index.rb +6 -0
- data/lib/pact_broker/api/resources/integrations.rb +18 -4
- data/lib/pact_broker/api/resources/latest_version.rb +2 -0
- data/lib/pact_broker/api/resources/pact.rb +16 -7
- data/lib/pact_broker/api/resources/pacticipant_branches.rb +67 -0
- data/lib/pact_broker/api/resources/pacticipants.rb +26 -7
- data/lib/pact_broker/api/resources/pacticipants_for_label.rb +2 -2
- data/lib/pact_broker/api/resources/pagination_methods.rb +11 -1
- data/lib/pact_broker/api/resources/publish_contracts.rb +1 -1
- data/lib/pact_broker/api/resources/verifications.rb +9 -4
- data/lib/pact_broker/api/resources/versions.rb +12 -0
- data/lib/pact_broker/api.rb +5 -0
- data/lib/pact_broker/app.rb +10 -9
- data/lib/pact_broker/application_context.rb +29 -25
- data/lib/pact_broker/async/after_reply.rb +30 -0
- data/lib/pact_broker/config/runtime_configuration.rb +9 -21
- data/lib/pact_broker/config/runtime_configuration_coercion_methods.rb +32 -2
- data/lib/pact_broker/config/runtime_configuration_database_methods.rb +1 -1
- data/lib/pact_broker/config/runtime_configuration_logging_methods.rb +15 -5
- data/lib/pact_broker/configuration.rb +29 -12
- data/lib/pact_broker/contracts/contract_to_publish.rb +4 -5
- data/lib/pact_broker/contracts/contracts_to_publish.rb +8 -0
- data/lib/pact_broker/contracts/service.rb +9 -3
- data/lib/pact_broker/dataset/page.rb +22 -0
- data/lib/pact_broker/dataset.rb +122 -0
- data/lib/pact_broker/db/data_migrations/set_contract_data_updated_at_for_integrations.rb +47 -0
- data/lib/pact_broker/db/migrate_data.rb +1 -0
- data/lib/pact_broker/db/models.rb +1 -1
- data/lib/pact_broker/deployments/currently_deployed_version_id.rb +2 -5
- data/lib/pact_broker/deployments/deployed_version.rb +3 -3
- data/lib/pact_broker/deployments/environment.rb +0 -2
- data/lib/pact_broker/deployments/released_version.rb +4 -5
- data/lib/pact_broker/doc/views/index/pacticipant-branch.markdown +25 -0
- data/lib/pact_broker/domain/label.rb +6 -3
- data/lib/pact_broker/domain/pact.rb +10 -5
- data/lib/pact_broker/domain/pacticipant.rb +4 -34
- data/lib/pact_broker/domain/tag.rb +4 -5
- data/lib/pact_broker/domain/verification.rb +2 -4
- data/lib/pact_broker/domain/version.rb +12 -19
- data/lib/pact_broker/errors/error_reporter.rb +30 -0
- data/lib/pact_broker/errors.rb +2 -15
- data/lib/pact_broker/events/subscriber.rb +12 -4
- data/lib/pact_broker/feature_toggle.rb +1 -1
- data/lib/pact_broker/groups/service.rb +38 -5
- data/lib/pact_broker/index/service.rb +1 -2
- data/lib/pact_broker/integrations/event_listener.rb +23 -0
- data/lib/pact_broker/integrations/integration.rb +24 -2
- data/lib/pact_broker/integrations/repository.rb +34 -1
- data/lib/pact_broker/integrations/service.rb +17 -18
- data/lib/pact_broker/labels/repository.rb +4 -8
- data/lib/pact_broker/locale/en.yml +5 -0
- data/lib/pact_broker/logging.rb +10 -0
- data/lib/pact_broker/matrix/every_row.rb +58 -40
- data/lib/pact_broker/matrix/integration_row.rb +95 -0
- data/lib/pact_broker/matrix/integrations_repository.rb +133 -0
- data/lib/pact_broker/matrix/matrix_row.rb +88 -0
- data/lib/pact_broker/matrix/matrix_row_dataset_module.rb +185 -0
- data/lib/pact_broker/matrix/matrix_row_instance_methods.rb +150 -0
- data/lib/pact_broker/matrix/matrix_row_verification_dataset_module.rb +83 -0
- data/lib/pact_broker/matrix/parse_query.rb +1 -0
- data/lib/pact_broker/matrix/repository.rb +62 -285
- data/lib/pact_broker/matrix/resolved_selector.rb +13 -4
- data/lib/pact_broker/matrix/resolved_selector_builder.rb +84 -0
- data/lib/pact_broker/matrix/resolved_selectors_builder.rb +39 -0
- data/lib/pact_broker/matrix/row_ignorer.rb +36 -0
- data/lib/pact_broker/matrix/selector_ignorer.rb +59 -0
- data/lib/pact_broker/matrix/selector_resolver.rb +130 -0
- data/lib/pact_broker/metrics/service.rb +4 -9
- data/lib/pact_broker/pacticipants/latest_version_for_pacticipant_eager_loader.rb +33 -0
- data/lib/pact_broker/pacticipants/repository.rb +7 -9
- data/lib/pact_broker/pacticipants/service.rb +2 -2
- data/lib/pact_broker/pacts/generate_sha.rb +9 -4
- data/lib/pact_broker/pacts/latest_pact_publication_id_for_consumer_version.rb +2 -4
- data/lib/pact_broker/pacts/metadata.rb +3 -1
- data/lib/pact_broker/pacts/pact_params.rb +1 -1
- data/lib/pact_broker/pacts/pact_publication.rb +23 -5
- data/lib/pact_broker/pacts/pact_publication_dataset_module.rb +5 -1
- data/lib/pact_broker/pacts/pact_version.rb +2 -3
- data/lib/pact_broker/pacts/pacts_for_verification_repository.rb +2 -5
- data/lib/pact_broker/pacts/placeholder_pact.rb +3 -1
- data/lib/pact_broker/pacts/repository.rb +12 -12
- data/lib/pact_broker/pacts/service.rb +12 -13
- data/lib/pact_broker/repositories.rb +9 -1
- data/lib/pact_broker/string_refinements.rb +4 -0
- data/lib/pact_broker/tags/head_pact_tags.rb +2 -5
- data/lib/pact_broker/tags/repository.rb +3 -7
- data/lib/pact_broker/test/test_data_builder.rb +57 -2
- data/lib/pact_broker/ui/controllers/base_controller.rb +4 -2
- data/lib/pact_broker/ui/controllers/groups.rb +2 -1
- data/lib/pact_broker/ui/view_models/matrix_line.rb +4 -4
- data/lib/pact_broker/ui/views/groups/show.html.erb +2 -1
- data/lib/pact_broker/ui.rb +20 -9
- data/lib/pact_broker/verifications/latest_verification_for_consumer_and_provider.rb +0 -3
- data/lib/pact_broker/verifications/latest_verification_id_for_pact_version_and_provider_version.rb +2 -4
- data/lib/pact_broker/verifications/repository.rb +2 -5
- data/lib/pact_broker/verifications/sequence.rb +1 -4
- data/lib/pact_broker/verifications/service.rb +4 -0
- data/lib/pact_broker/version.rb +1 -1
- data/lib/pact_broker/versions/branch.rb +2 -5
- data/lib/pact_broker/versions/branch_head.rb +0 -3
- data/lib/pact_broker/versions/branch_repository.rb +76 -0
- data/lib/pact_broker/versions/branch_service.rb +13 -25
- data/lib/pact_broker/versions/branch_version.rb +0 -3
- data/lib/pact_broker/versions/branch_version_repository.rb +17 -0
- data/lib/pact_broker/versions/repository.rb +19 -2
- data/lib/pact_broker/versions/sequence.rb +1 -3
- data/lib/pact_broker/versions/service.rb +4 -0
- data/lib/pact_broker/webhooks/execution.rb +3 -7
- data/lib/pact_broker/webhooks/job.rb +16 -7
- data/lib/pact_broker/webhooks/pact_and_verification_parameters.rb +2 -2
- data/lib/pact_broker/webhooks/repository.rb +0 -1
- data/lib/pact_broker/webhooks/trigger_service.rb +11 -12
- data/lib/pact_broker/webhooks/triggered_webhook.rb +3 -4
- data/lib/pact_broker/webhooks/webhook.rb +2 -2
- data/lib/pact_broker/webhooks/webhook_event.rb +2 -5
- data/lib/rack/pact_broker/add_cache_header.rb +14 -0
- data/lib/rack/pact_broker/application_context.rb +16 -0
- data/lib/rack/pact_broker/configurable_make_it_later.rb +1 -1
- data/lib/rack/pact_broker/invalid_uri_protection.rb +19 -3
- data/lib/webmachine/describe_routes.rb +55 -39
- data/lib/webmachine/render_error_monkey_patch.rb +13 -4
- data/pact_broker.gemspec +5 -5
- metadata +54 -31
- data/lib/pact_broker/api/decorators/decorator_context.rb +0 -22
- data/lib/pact_broker/matrix/query_builder.rb +0 -90
- data/lib/pact_broker/matrix/query_ids.rb +0 -40
- data/lib/pact_broker/matrix/quick_row.rb +0 -458
- data/lib/pact_broker/relationships/groupify.rb +0 -45
- data/lib/pact_broker/repositories/helpers.rb +0 -96
- data/lib/pact_broker/repositories/page.rb +0 -24
- data/lib/pact_broker/tags/tag_with_latest_flag.rb +0 -28
@@ -4,7 +4,9 @@ require "pact_broker/hash_refinements"
|
|
4
4
|
# This is created from either specified or inferred data, based on the user's query
|
5
5
|
# eg.
|
6
6
|
# can-i-deploy --pacticipant Foo --version 1 (this is a specified selector)
|
7
|
-
# --to prod (this is used to create inferred selectors)
|
7
|
+
# --to prod (this is used to create inferred selectors, one for each integrated pacticipant in that environment)
|
8
|
+
# When an UnresolvedSelector specifies multiple application versions (eg. { tag: "prod" }) then a ResolvedSelector
|
9
|
+
# is created for every Version object found for the original selector.
|
8
10
|
|
9
11
|
module PactBroker
|
10
12
|
module Matrix
|
@@ -31,6 +33,9 @@ module PactBroker
|
|
31
33
|
)
|
32
34
|
end
|
33
35
|
|
36
|
+
# This is not possible for specified selectors, as there is validation at the HTTP query level to
|
37
|
+
# ensure that all pacticipants in the specified selectors exist.
|
38
|
+
# It is possible for the ignore selectors however.
|
34
39
|
def self.for_non_existing_pacticipant(original_selector, type, ignore)
|
35
40
|
ResolvedSelector.new(
|
36
41
|
pacticipant_id: NULL_PACTICIPANT_ID,
|
@@ -187,16 +192,20 @@ module PactBroker
|
|
187
192
|
!ignore?
|
188
193
|
end
|
189
194
|
|
195
|
+
def original_selector
|
196
|
+
self[:original_selector]
|
197
|
+
end
|
198
|
+
|
190
199
|
# rubocop: disable Metrics/CyclomaticComplexity, Metrics/MethodLength
|
191
200
|
def description
|
192
201
|
if latest_tagged? && pacticipant_version_number
|
193
202
|
"the latest version of #{pacticipant_name} with tag #{tag} (#{pacticipant_version_number})"
|
194
203
|
elsif latest_tagged?
|
195
204
|
"the latest version of #{pacticipant_name} with tag #{tag} (no such version exists)"
|
196
|
-
elsif main_branch? && pacticipant_version_number.nil?
|
197
|
-
"a version of #{pacticipant_name} from the main branch (no such version exists)"
|
198
205
|
elsif latest_from_main_branch? && pacticipant_version_number.nil?
|
199
|
-
"the latest version of #{pacticipant_name} from the main branch (no
|
206
|
+
"the latest version of #{pacticipant_name} from the main branch (no versions exist for this branch)"
|
207
|
+
elsif main_branch? && pacticipant_version_number.nil?
|
208
|
+
"any version of #{pacticipant_name} from the main branch (no versions exist for this branch)"
|
200
209
|
elsif latest_from_branch? && pacticipant_version_number
|
201
210
|
"the latest version of #{pacticipant_name} from branch #{branch} (#{pacticipant_version_number})"
|
202
211
|
elsif latest_from_branch?
|
@@ -0,0 +1,84 @@
|
|
1
|
+
# Builds a PactBroker::Matrix::UnresolvedSelector based on the given
|
2
|
+
# UnresolvedSelector, selector type, Pacticipant and Version objects,
|
3
|
+
# using the selector_ignorer to work out if the built ResolvedSelector
|
4
|
+
# should be marked as ignored or not.
|
5
|
+
|
6
|
+
module PactBroker
|
7
|
+
module Matrix
|
8
|
+
class ResolvedSelectorBuilder
|
9
|
+
|
10
|
+
attr_accessor :pacticipant, :versions
|
11
|
+
|
12
|
+
# @param [PactBroker::Matrix::UnresolvedSelector] unresolved_selector
|
13
|
+
# @param [Symbol] selector_type :specified or :inferred
|
14
|
+
# @param [PactBroker::Matrix::Ignorer] selector_ignorer
|
15
|
+
def initialize(unresolved_selector, selector_type, selector_ignorer)
|
16
|
+
@unresolved_selector = unresolved_selector
|
17
|
+
@selector_type = selector_type
|
18
|
+
@selector_ignorer = selector_ignorer
|
19
|
+
end
|
20
|
+
|
21
|
+
def build
|
22
|
+
if pacticipant && versions
|
23
|
+
build_resolved_selectors_for_versions(pacticipant, versions, unresolved_selector, selector_type)
|
24
|
+
elsif pacticipant
|
25
|
+
selector_for_all_versions_of_a_pacticipant(pacticipant, unresolved_selector, selector_type)
|
26
|
+
else
|
27
|
+
build_selector_for_non_existing_pacticipant(unresolved_selector, selector_type)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
attr_reader :unresolved_selector, :selector_type, :selector_ignorer
|
34
|
+
|
35
|
+
# When a single selector specifies multiple versions (eg. "all prod pacts"), this expands
|
36
|
+
# the single selector into one selector for each version.
|
37
|
+
# When a pacticipant is found, but there are no versions matching the selector,
|
38
|
+
# the versions array will be have a single item which is nil (`[nil]`).
|
39
|
+
# See PactBroker::Matrix::SelectorResolver#find_versions_for_selector
|
40
|
+
# There may be a better way to pass in this information.
|
41
|
+
def build_resolved_selectors_for_versions(pacticipant, versions, unresolved_selector, selector_type)
|
42
|
+
one_of_many = versions.compact.size > 1
|
43
|
+
versions.collect do | version |
|
44
|
+
if version
|
45
|
+
selector_for_found_version(pacticipant, version, unresolved_selector, selector_type, one_of_many)
|
46
|
+
else
|
47
|
+
selector_for_non_existing_version(pacticipant, unresolved_selector, selector_type)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def selector_for_non_existing_version(pacticipant, unresolved_selector, selector_type)
|
53
|
+
ignore = selector_ignorer.ignore_pacticipant?(pacticipant)
|
54
|
+
ResolvedSelector.for_pacticipant_and_non_existing_version(pacticipant, unresolved_selector, selector_type, ignore)
|
55
|
+
end
|
56
|
+
|
57
|
+
def selector_for_found_version(pacticipant, version, unresolved_selector, selector_type, one_of_many)
|
58
|
+
ResolvedSelector.for_pacticipant_and_version(
|
59
|
+
pacticipant,
|
60
|
+
version,
|
61
|
+
unresolved_selector,
|
62
|
+
selector_type,
|
63
|
+
selector_ignorer.ignore_pacticipant_version?(pacticipant, version),
|
64
|
+
one_of_many
|
65
|
+
)
|
66
|
+
end
|
67
|
+
|
68
|
+
def selector_for_all_versions_of_a_pacticipant(pacticipant, unresolved_selector, selector_type)
|
69
|
+
ResolvedSelector.for_pacticipant(
|
70
|
+
pacticipant,
|
71
|
+
unresolved_selector,
|
72
|
+
selector_type,
|
73
|
+
selector_ignorer.ignore_pacticipant?(pacticipant)
|
74
|
+
)
|
75
|
+
end
|
76
|
+
|
77
|
+
# only relevant for ignore selectors, validation stops this happening for the normal
|
78
|
+
# selectors
|
79
|
+
def build_selector_for_non_existing_pacticipant(unresolved_selector, selector_type)
|
80
|
+
ResolvedSelector.for_non_existing_pacticipant(unresolved_selector, selector_type, false)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require "pact_broker/matrix/selector_resolver"
|
2
|
+
|
3
|
+
# Builds the array of ResolvedSelector objects using the
|
4
|
+
# ignore selectors, the specified selectors, and the inferred integrations.
|
5
|
+
|
6
|
+
module PactBroker
|
7
|
+
module Matrix
|
8
|
+
class ResolvedSelectorsBuilder
|
9
|
+
attr_reader :ignore_selectors, :specified_selectors, :inferred_selectors
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
@inferred_selectors = []
|
13
|
+
end
|
14
|
+
|
15
|
+
# @param [Array<PactBroker::Matrix::UnresolvedSelector>]
|
16
|
+
# @param [Hash] options
|
17
|
+
def resolve_selectors(unresolved_specified_selectors, unresolved_ignore_selectors)
|
18
|
+
# must do this first because we need the ignore selectors to resolve the specified selectors
|
19
|
+
@ignore_selectors = SelectorResolver.resolved_ignore_selectors(unresolved_ignore_selectors)
|
20
|
+
@specified_selectors = SelectorResolver.resolve_specified_selectors(unresolved_specified_selectors, ignore_selectors)
|
21
|
+
end
|
22
|
+
|
23
|
+
# Use the given Integrations to work out what the selectors are for the versions that the versions for the specified
|
24
|
+
# selectors should be deployed with.
|
25
|
+
# eg. For `can-i-deploy --pacticipant Foo --version adfjkwejr --to-environment prod`, work out the selectors for the integrated application
|
26
|
+
# versions in the prod environment.
|
27
|
+
# @param [Array<PactBroker::Matrix::Integration>] integrations
|
28
|
+
def resolve_inferred_selectors(integrations, options)
|
29
|
+
@inferred_selectors = SelectorResolver.resolve_inferred_selectors(specified_selectors, ignore_selectors, integrations, options)
|
30
|
+
end
|
31
|
+
|
32
|
+
# All the resolved selectors to be used in the matrix query, specified and inferred (if any)
|
33
|
+
# @return [Array<PactBroker::Matrix::ResolvedSelector>]
|
34
|
+
def all_selectors
|
35
|
+
specified_selectors + inferred_selectors
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module PactBroker
|
2
|
+
module Matrix
|
3
|
+
class RowIgnorer
|
4
|
+
|
5
|
+
class << self
|
6
|
+
# Splits the matrix rows into considered rows and ignored rows, based on the
|
7
|
+
# ignore selectors specified by the user in the can-i-deploy command (eg. --ignore SomeProviderThatIsNotReadyYet).
|
8
|
+
# @param [Array<MatrixRow, EveryRow>] rows
|
9
|
+
# @param [<PactBroker::Matrix::ResolvedSelector>] resolved_ignore_selectors
|
10
|
+
# @return [Array<MatrixRow, EveryRow>] considered_rows, [Array<MatrixRow, EveryRow>] ignored_rows
|
11
|
+
def split_rows_into_considered_and_ignored(rows, resolved_ignore_selectors)
|
12
|
+
if resolved_ignore_selectors.any?
|
13
|
+
considered, ignored = [], []
|
14
|
+
rows.each do | row |
|
15
|
+
if ignore_row?(resolved_ignore_selectors, row)
|
16
|
+
ignored << row
|
17
|
+
else
|
18
|
+
considered << row
|
19
|
+
end
|
20
|
+
end
|
21
|
+
return considered, ignored
|
22
|
+
else
|
23
|
+
return rows, []
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def ignore_row?(resolved_ignore_selectors, row)
|
28
|
+
resolved_ignore_selectors.any? do | s |
|
29
|
+
s.pacticipant_id == row.consumer_id && (s.only_pacticipant_name_specified? || s.pacticipant_version_id == row.consumer_version_id) ||
|
30
|
+
s.pacticipant_id == row.provider_id && (s.only_pacticipant_name_specified? || s.pacticipant_version_id == row.provider_version_id)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# This class determines whether or not a resolved selector (both specified and inferred)
|
2
|
+
# that is about to be created should be marked as "ignored".
|
3
|
+
# It uses the ignore selectors are provided in the can-i-deploy CLI command like so:
|
4
|
+
# can-i-deploy --pacticipant Foo --version 234243 --to-environment prod --ignore SomeProviderThatIsNotReadyYet [--version SomeOptionalVersion]
|
5
|
+
# The ignored flag on the ResolvedSelector is used to determine whether or not a failing/missing row
|
6
|
+
# in the can-i-deploy matrix should be ignored.
|
7
|
+
# This allows can-i-deploy to pass successfully when a dependency is known to be not ready,
|
8
|
+
# but the developer wants to deploy the application anyway.
|
9
|
+
|
10
|
+
# The only reason why we need to resolve the ignore selectors is that we check in PactBroker::Matrix::DeploymentStatusSummary
|
11
|
+
# whether or not the pacticipant or version they specify actually exist.
|
12
|
+
# We could actually have performed the ignore checks just using the name and version number.
|
13
|
+
|
14
|
+
module PactBroker
|
15
|
+
module Matrix
|
16
|
+
class SelectorIgnorer
|
17
|
+
|
18
|
+
# @param [Array<PactBroker::Matrix::UnresolvedSelector>] resolved_ignore_selectors
|
19
|
+
def initialize(resolved_ignore_selectors)
|
20
|
+
@resolved_ignore_selectors = resolved_ignore_selectors
|
21
|
+
end
|
22
|
+
|
23
|
+
# Whether the pacticipant should be ignored if the verification results are missing/failed.
|
24
|
+
# @param [PactBroker::Domain::Pacticipant] pacticipant
|
25
|
+
# @return [Boolean]
|
26
|
+
def ignore_pacticipant?(pacticipant)
|
27
|
+
resolved_ignore_selectors.any? do | s |
|
28
|
+
s.pacticipant_id == pacticipant.id && s.only_pacticipant_name_specified?
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
# Whether the pacticipant version should be ignored if the verification results are missing/failed.
|
33
|
+
# @param [PactBroker::Domain::Pacticipant] pacticipant
|
34
|
+
# @param [PactBroker::Domain::Version] version
|
35
|
+
# @return [Boolean]
|
36
|
+
def ignore_pacticipant_version?(pacticipant, version)
|
37
|
+
resolved_ignore_selectors.any? do | s |
|
38
|
+
s.pacticipant_id == pacticipant.id && (s.only_pacticipant_name_specified? || s.pacticipant_version_id == version.id)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
attr_reader :resolved_ignore_selectors
|
45
|
+
end
|
46
|
+
|
47
|
+
# Used when resolving the ignore selecors in the first place - the process for resolving normal selectors
|
48
|
+
# and ignore selectors is almost the same, but it makes no sense to ignore an ignore selector.
|
49
|
+
class NilSelectorIgnorer
|
50
|
+
def ignore_pacticipant?(*)
|
51
|
+
false
|
52
|
+
end
|
53
|
+
|
54
|
+
def ignore_pacticipant_version?(*)
|
55
|
+
false
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,130 @@
|
|
1
|
+
require "pact_broker/repositories"
|
2
|
+
require "pact_broker/matrix/resolved_selector"
|
3
|
+
require "pact_broker/matrix/resolved_selector_builder"
|
4
|
+
require "pact_broker/matrix/selector_ignorer"
|
5
|
+
|
6
|
+
|
7
|
+
# Take the selectors and options provided by the user (eg. [{ pacticipant_name: "Foo", pacticipant_version_number: "1" }], { to_environment: "prod" })
|
8
|
+
# that use pacticipant/version/branch/environment names,
|
9
|
+
# and look up the IDs of all the objects, and return them as ResolvedSelector objects.
|
10
|
+
# For unresolved selectors that specify a collection of versions (eg. { branch: "main" }) a ResolvedSelector
|
11
|
+
# will be returned for every pacticipant version found. This will eventually be used in the can-i-deploy
|
12
|
+
# logic in PactBroker::Matrix::DeploymentStatusSummary to work out if there are any missing verifications.
|
13
|
+
|
14
|
+
module PactBroker
|
15
|
+
module Matrix
|
16
|
+
class SelectorResolver
|
17
|
+
class << self
|
18
|
+
include PactBroker::Repositories
|
19
|
+
|
20
|
+
# Resolve any ignore selectors used in the can-i-deploy command e.g `--ignore SomeProviderThatIsNotReadyYet`
|
21
|
+
# @param [Array<PactBroker::Matrix::UnresolvedSelector>] unresolved_ignore_selectors
|
22
|
+
# @return [Array<PactBroker::Matrix::ResolvedSelector>]
|
23
|
+
def resolved_ignore_selectors(unresolved_ignore_selectors)
|
24
|
+
# When resolving the ignore_selectors, use the NilSelectorIgnorer because it doesn't make sense to ignore
|
25
|
+
# the ignore selectors.
|
26
|
+
resolve_versions_and_add_ids(unresolved_ignore_selectors, :ignored, NilSelectorIgnorer.new)
|
27
|
+
end
|
28
|
+
|
29
|
+
# Resolve the selectors that were specified in the can-i-deploy command eg. `--pacticipant Foo --version 43434`
|
30
|
+
# There may be one or multiple.
|
31
|
+
# @param [Array<PactBroker::Matrix::UnresolvedSelector>] unresolved_specified_selectors
|
32
|
+
# @param [Array<PactBroker::Matrix::ResolvedSelector>] resolved_ignore_selectors previously resolved selectors for the versions to ignore
|
33
|
+
# @return [Array<PactBroker::Matrix::ResolvedSelector>]
|
34
|
+
def resolve_specified_selectors(unresolved_specified_selectors, resolved_ignore_selectors)
|
35
|
+
resolve_versions_and_add_ids(unresolved_specified_selectors, :specified, SelectorIgnorer.new(resolved_ignore_selectors))
|
36
|
+
end
|
37
|
+
|
38
|
+
# When the can-i-deploy command uses any of the `--to` options (eg. `--to-environment ENV` or `--to TAG`)
|
39
|
+
# we need to create the inferred selectors for the pacticipant versions in that environment/with that tag/branch.
|
40
|
+
# eg. if A -> B, and the CLI command is `can-i-deploy --pacticipant A --version 3434 --to-environment prod`,
|
41
|
+
# then we need to make the inferred selector for pacticipant B with the version that is in prod.
|
42
|
+
# @param [Array<PactBroker::Matrix::ResolvedSelector>] resolved_specified_selectors
|
43
|
+
# @param [Array<PactBroker::Matrix::ResolvedSelector>] resolved_ignore_selectors
|
44
|
+
# @param [Array<PactBroker::Matrix::Integration>] integrations
|
45
|
+
# @param [Hash] options
|
46
|
+
# @return [Array<PactBroker::Matrix::ResolvedSelector>]
|
47
|
+
def resolve_inferred_selectors(resolved_specified_selectors, resolved_ignore_selectors, integrations, options)
|
48
|
+
all_pacticipant_names = integrations.collect(&:pacticipant_names).flatten.uniq
|
49
|
+
specified_names = resolved_specified_selectors.collect{ |s| s[:pacticipant_name] }
|
50
|
+
inferred_pacticipant_names = all_pacticipant_names - specified_names
|
51
|
+
unresolved_selectors = build_unresolved_selectors_for_inferred_pacticipants(inferred_pacticipant_names, options)
|
52
|
+
resolve_versions_and_add_ids(unresolved_selectors, :inferred, SelectorIgnorer.new(resolved_ignore_selectors))
|
53
|
+
end
|
54
|
+
|
55
|
+
# Find the IDs of every pacticipant and version in the UnresolvedSelectors, and return them as ResolvedSelectors,
|
56
|
+
# expanding selectors for multiple versions.
|
57
|
+
# This gets called first for the ignore selectors, then the specified selectors, and then the inferred selectors.
|
58
|
+
# When it gets called for the first time for the ignore selectors, they will be passed in as the unresolved_selectors, and the resolved_ignore_selectors
|
59
|
+
# will be empty.
|
60
|
+
# The next times it is called with the specified selectors and the inferred selectors, the previously resolved ignore selectors will be passed in
|
61
|
+
# as resolved_ignore_selectors so we can work out which of those selectors needs to be ignored.
|
62
|
+
#
|
63
|
+
# @param [Array<PactBroker::Matrix::UnresolvedSelector>] unresolved_selectors
|
64
|
+
# @param [Symbol] selector_type which may be :specified or :inferred
|
65
|
+
# @param [SelectorIgnorer] selector_ignorer
|
66
|
+
# @return [Array<PactBroker::Matrix::ResolvedSelector>]
|
67
|
+
def resolve_versions_and_add_ids(unresolved_selectors, selector_type, selector_ignorer)
|
68
|
+
pacticipants_hash = find_pacticipants_for_selectors(unresolved_selectors)
|
69
|
+
unresolved_selectors.collect do | unresolved_selector |
|
70
|
+
build_selectors(pacticipants_hash, unresolved_selector, selector_type, selector_ignorer)
|
71
|
+
end.flatten
|
72
|
+
end
|
73
|
+
|
74
|
+
private :resolve_versions_and_add_ids
|
75
|
+
|
76
|
+
# Return a Hash of the pacticipant names used in the selectors, where the key is the name and the value is the pacticipant
|
77
|
+
# @return [Hash<String, PactBroker::Domain::Pacticipant>]
|
78
|
+
def find_pacticipants_for_selectors(unresolved_selectors)
|
79
|
+
names = unresolved_selectors.collect(&:pacticipant_name)
|
80
|
+
PactBroker::Domain::Pacticipant.where(name: names).all.group_by(&:name).transform_values(&:first)
|
81
|
+
end
|
82
|
+
|
83
|
+
private :find_pacticipants_for_selectors
|
84
|
+
|
85
|
+
def build_selectors(pacticipants_hash, unresolved_selector, selector_type, selector_ignorer)
|
86
|
+
selector_builder = ResolvedSelectorBuilder.new(unresolved_selector, selector_type, selector_ignorer)
|
87
|
+
selector_builder.pacticipant = pacticipants_hash[unresolved_selector.pacticipant_name]
|
88
|
+
if selector_builder.pacticipant
|
89
|
+
versions = find_versions_for_selector(unresolved_selector)
|
90
|
+
selector_builder.versions = versions
|
91
|
+
end
|
92
|
+
selector_builder.build
|
93
|
+
end
|
94
|
+
|
95
|
+
# Find the pacticipant versions for the unresolved selector.
|
96
|
+
# @param [PactBroker::Matrix::UnresolvedSelector] unresolved_selector
|
97
|
+
def find_versions_for_selector(unresolved_selector)
|
98
|
+
# For selectors that just set the pacticipant name, there's no need to resolve the version -
|
99
|
+
# only the pacticipant ID will be used in the query
|
100
|
+
return nil if unresolved_selector.all_for_pacticipant?
|
101
|
+
versions = version_repository.find_versions_for_selector(unresolved_selector)
|
102
|
+
|
103
|
+
if unresolved_selector.latest
|
104
|
+
[versions.first]
|
105
|
+
else
|
106
|
+
versions.empty? ? [nil] : versions
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
private :find_versions_for_selector
|
111
|
+
|
112
|
+
# Build an unresolved selector for the integrations that we have inferred for the target environment/branch/tag
|
113
|
+
# @param [Array<String>] inferred_pacticipant_names the names of the pacticipants that we have determined to be integrated with the versions for the specified selectors
|
114
|
+
def build_unresolved_selectors_for_inferred_pacticipants(inferred_pacticipant_names, options)
|
115
|
+
inferred_pacticipant_names.collect do | pacticipant_name |
|
116
|
+
selector = UnresolvedSelector.new(pacticipant_name: pacticipant_name)
|
117
|
+
selector.tag = options[:tag] if options[:tag]
|
118
|
+
selector.branch = options[:branch] if options[:branch]
|
119
|
+
selector.main_branch = options[:main_branch] if options[:main_branch]
|
120
|
+
selector.latest = options[:latest] if options[:latest]
|
121
|
+
selector.environment_name = options[:environment_name] if options[:environment_name]
|
122
|
+
selector
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
private :build_unresolved_selectors_for_inferred_pacticipants
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
@@ -101,8 +101,8 @@ module PactBroker
|
|
101
101
|
end
|
102
102
|
|
103
103
|
def pact_revision_counts
|
104
|
-
query = "select revision_count as number_of_revisions, count(
|
105
|
-
from (select
|
104
|
+
query = "select revision_count as number_of_revisions, count(*) as consumer_version_count
|
105
|
+
from (select count(*) as revision_count from pact_publications group by consumer_version_id, provider_id) foo
|
106
106
|
group by revision_count
|
107
107
|
order by 1"
|
108
108
|
PactBroker::Pacts::PactPublication.db[query].all.each_with_object({}) { |row, hash| hash[row[:number_of_revisions]] = row[:consumer_version_count] }
|
@@ -116,14 +116,9 @@ module PactBroker
|
|
116
116
|
PactBroker::Pacts::PactPublication.db[query].all.each_with_object({}) { |row, hash| hash[row[:number_of_verifications]] = row[:pact_version_count] }
|
117
117
|
end
|
118
118
|
|
119
|
+
# This count has no real meaning and takes too long to do. Hardcode it to -1
|
119
120
|
def matrix_count
|
120
|
-
|
121
|
-
PactBroker::Matrix::EveryRow.db.with_statement_timeout(PactBroker.configuration.metrics_sql_statement_timeout) do
|
122
|
-
PactBroker::Matrix::EveryRow.default_scope.count
|
123
|
-
end
|
124
|
-
rescue Sequel::DatabaseError => _ex
|
125
|
-
-1
|
126
|
-
end
|
121
|
+
-1
|
127
122
|
end
|
128
123
|
end
|
129
124
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module PactBroker
|
2
|
+
module Pacticipants
|
3
|
+
class LatestVersionForPacticipantEagerLoader
|
4
|
+
def self.call(eo, **_other)
|
5
|
+
populate_associations(eo[:rows])
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.populate_associations(pacticipants)
|
9
|
+
pacticipants.each { | pacticipant | pacticipant.associations[:latest_version] = nil }
|
10
|
+
pacticipant_ids = pacticipants.collect(&:id)
|
11
|
+
|
12
|
+
max_orders = PactBroker::Domain::Version
|
13
|
+
.where(pacticipant_id: pacticipant_ids)
|
14
|
+
.select_group(:pacticipant_id)
|
15
|
+
.select_append { max(order).as(latest_order) }
|
16
|
+
|
17
|
+
max_orders_join = {
|
18
|
+
Sequel[:max_orders][:latest_order] => Sequel[:versions][:order],
|
19
|
+
Sequel[:max_orders][:pacticipant_id] => Sequel[:versions][:pacticipant_id]
|
20
|
+
}
|
21
|
+
|
22
|
+
latest_versions = PactBroker::Domain::Version
|
23
|
+
.select_all_qualified
|
24
|
+
.join(max_orders, max_orders_join, { table_alias: :max_orders})
|
25
|
+
|
26
|
+
latest_versions.each do | version |
|
27
|
+
pacticipant = pacticipants.find{ | p | p.id == version.pacticipant_id }
|
28
|
+
pacticipant.associations[:latest_version] = version
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -1,6 +1,4 @@
|
|
1
|
-
require "sequel"
|
2
1
|
require "pact_broker/domain/pacticipant"
|
3
|
-
require "pact_broker/repositories/helpers"
|
4
2
|
require "pact_broker/error"
|
5
3
|
require "pact_broker/repositories/scopes"
|
6
4
|
|
@@ -9,11 +7,10 @@ module PactBroker
|
|
9
7
|
class Repository
|
10
8
|
|
11
9
|
include PactBroker::Repositories
|
12
|
-
include PactBroker::Repositories::Helpers
|
13
10
|
include PactBroker::Repositories::Scopes
|
14
11
|
|
15
12
|
def find_by_name name
|
16
|
-
pacticipants = PactBroker::Domain::Pacticipant.where(name_like(:name, name)).all
|
13
|
+
pacticipants = PactBroker::Domain::Pacticipant.where(Sequel.name_like(:name, name)).all
|
17
14
|
handle_multiple_pacticipants_found(name, pacticipants) if pacticipants.size > 1
|
18
15
|
pacticipants.first
|
19
16
|
end
|
@@ -27,7 +24,7 @@ module PactBroker
|
|
27
24
|
# @param [Array<String>] the array of names by which to find the pacticipants
|
28
25
|
def find_by_names(names)
|
29
26
|
return [] if names.empty?
|
30
|
-
name_likes = names.collect{ | name | name_like(:name, name) }
|
27
|
+
name_likes = names.collect{ | name | Sequel.name_like(:name, name) }
|
31
28
|
scope_for(PactBroker::Domain::Pacticipant).where(Sequel.|(*name_likes)).all
|
32
29
|
end
|
33
30
|
|
@@ -35,14 +32,15 @@ module PactBroker
|
|
35
32
|
PactBroker::Domain::Pacticipant.where(id: id).single_record
|
36
33
|
end
|
37
34
|
|
38
|
-
def find_all(pagination_options = {})
|
39
|
-
find(
|
35
|
+
def find_all(options = {}, pagination_options = {}, eager_load_associations = [])
|
36
|
+
find(options, pagination_options, eager_load_associations)
|
40
37
|
end
|
41
38
|
|
42
|
-
def find(options = {}, pagination_options = {})
|
39
|
+
def find(options = {}, pagination_options = {}, eager_load_associations = [])
|
43
40
|
query = scope_for(PactBroker::Domain::Pacticipant).select_all_qualified
|
41
|
+
query = query.filter(:name, options[:query_string]) if options[:query_string]
|
44
42
|
query = query.label(options[:label_name]) if options[:label_name]
|
45
|
-
query.order_ignore_case(Sequel[:pacticipants][:name]).eager(
|
43
|
+
query.order_ignore_case(Sequel[:pacticipants][:name]).eager(*eager_load_associations).all_with_pagination_options(pagination_options)
|
46
44
|
end
|
47
45
|
|
48
46
|
def find_by_name_or_create name
|
@@ -32,8 +32,8 @@ module PactBroker
|
|
32
32
|
} .collect{ | name | pacticipant_repository.find_by_name(name) }
|
33
33
|
end
|
34
34
|
|
35
|
-
def self.find_all_pacticipants(pagination_options = {})
|
36
|
-
pacticipant_repository.find_all(pagination_options)
|
35
|
+
def self.find_all_pacticipants(filter_options = {}, pagination_options = {}, eager_load_associations = [])
|
36
|
+
pacticipant_repository.find_all(filter_options, pagination_options, eager_load_associations)
|
37
37
|
end
|
38
38
|
|
39
39
|
def self.find_pacticipant_by_name(name)
|
@@ -3,22 +3,27 @@ require "pact_broker/configuration"
|
|
3
3
|
require "pact_broker/pacts/sort_content"
|
4
4
|
require "pact_broker/pacts/parse"
|
5
5
|
require "pact_broker/pacts/content"
|
6
|
+
require "pact_broker/logging"
|
6
7
|
|
7
8
|
module PactBroker
|
8
9
|
module Pacts
|
9
10
|
class GenerateSha
|
11
|
+
include PactBroker::Logging
|
12
|
+
|
10
13
|
# @param [String] json_content
|
11
|
-
def self.call
|
14
|
+
def self.call(json_content, _options = {})
|
12
15
|
content_for_sha = if PactBroker.configuration.base_equality_only_on_content_that_affects_verification_results
|
13
16
|
extract_verifiable_content_for_sha(json_content)
|
14
17
|
else
|
15
18
|
json_content
|
16
19
|
end
|
17
|
-
Digest::SHA1.hexdigest(content_for_sha)
|
20
|
+
measure_info("Generating SHA1 hexdigest for pact", payload: { length: content_for_sha.length } ){ Digest::SHA1.hexdigest(content_for_sha) }
|
18
21
|
end
|
19
22
|
|
20
|
-
def self.extract_verifiable_content_for_sha
|
21
|
-
Content.from_json(json_content)
|
23
|
+
def self.extract_verifiable_content_for_sha(json_content)
|
24
|
+
objects = Content.from_json(json_content)
|
25
|
+
sorted_content = measure_info("Sorting content", payload: { length: json_content.length }){ objects.sort }
|
26
|
+
sorted_content.content_that_affects_verification_results.to_json
|
22
27
|
end
|
23
28
|
end
|
24
29
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require "pact_broker/
|
1
|
+
require "pact_broker/dataset"
|
2
2
|
|
3
3
|
module PactBroker
|
4
4
|
module Pacts
|
@@ -7,9 +7,7 @@ module PactBroker
|
|
7
7
|
unrestrict_primary_key
|
8
8
|
plugin :upsert, identifying_columns: [:provider_id, :consumer_version_id]
|
9
9
|
|
10
|
-
dataset_module
|
11
|
-
include PactBroker::Repositories::Helpers
|
12
|
-
end
|
10
|
+
dataset_module PactBroker::Dataset
|
13
11
|
end
|
14
12
|
end
|
15
13
|
end
|
@@ -12,6 +12,7 @@ module PactBroker
|
|
12
12
|
[:consumer_version_selectors, "s"],
|
13
13
|
[:tag, "t"],
|
14
14
|
[:branch, "b"],
|
15
|
+
[:environment, "e"],
|
15
16
|
[:latest, "l"]
|
16
17
|
]
|
17
18
|
|
@@ -45,6 +46,7 @@ module PactBroker
|
|
45
46
|
# parameters. This is part of ensuring that verification results webhooks
|
46
47
|
# go back to the correct consumer version number (eg for git statuses)
|
47
48
|
def build_metadata_for_webhook_triggered_by_pact_publication(pact)
|
49
|
+
# Should probably put the branch in here, but I don't think the tags are used for anything
|
48
50
|
metadata = {
|
49
51
|
"cvn" => pact.consumer_version_number,
|
50
52
|
"cvt" => pact.consumer_version_tag_names
|
@@ -60,13 +62,13 @@ module PactBroker
|
|
60
62
|
"w" => true
|
61
63
|
}
|
62
64
|
else
|
63
|
-
# TODO support deployed and released
|
64
65
|
{
|
65
66
|
"s" => verifiable_pact.selectors.collect do | selector |
|
66
67
|
{
|
67
68
|
"b" => selector.branch,
|
68
69
|
"t" => selector.tag,
|
69
70
|
"l" => selector.latest,
|
71
|
+
"e" => selector.environment_name,
|
70
72
|
"cv" => selector.consumer_version.id
|
71
73
|
}.compact
|
72
74
|
end,
|