pact_broker 2.107.1 → 2.108.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 +55 -0
- data/Gemfile +5 -4
- 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/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_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/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 +11 -6
- 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/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 -4
- 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/contracts_to_publish.rb +8 -0
- data/lib/pact_broker/contracts/service.rb +7 -1
- 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/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/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_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 +1 -1
- 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 +50 -1
- 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/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 +4 -4
- metadata +52 -29
- 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
@@ -47,6 +47,10 @@ module PactBroker
|
|
47
47
|
get_repository(:matrix_repository)
|
48
48
|
end
|
49
49
|
|
50
|
+
def branch_repository
|
51
|
+
get_repository(:branch_repository)
|
52
|
+
end
|
53
|
+
|
50
54
|
def branch_version_repository
|
51
55
|
get_repository(:branch_version_repository)
|
52
56
|
end
|
@@ -96,6 +100,11 @@ module PactBroker
|
|
96
100
|
Matrix::Repository.new
|
97
101
|
end
|
98
102
|
|
103
|
+
register_repository(:branch_repository) do
|
104
|
+
require "pact_broker/versions/branch_repository"
|
105
|
+
PactBroker::Versions::BranchRepository.new
|
106
|
+
end
|
107
|
+
|
99
108
|
register_repository(:branch_version_repository) do
|
100
109
|
require "pact_broker/versions/branch_version_repository"
|
101
110
|
PactBroker::Versions::BranchVersionRepository.new
|
@@ -105,7 +114,6 @@ module PactBroker
|
|
105
114
|
require "pact_broker/integrations/repository"
|
106
115
|
PactBroker::Integrations::Repository.new
|
107
116
|
end
|
108
|
-
|
109
117
|
# rubocop: enable Metrics/MethodLength
|
110
118
|
end
|
111
119
|
end
|
@@ -1,12 +1,9 @@
|
|
1
|
-
require "pact_broker/
|
2
|
-
require "pact_broker/repositories/helpers"
|
1
|
+
require "pact_broker/dataset"
|
3
2
|
|
4
3
|
module PactBroker
|
5
4
|
module Tags
|
6
5
|
class HeadPactTag < Sequel::Model
|
7
|
-
dataset_module
|
8
|
-
include PactBroker::Repositories::Helpers
|
9
|
-
end
|
6
|
+
dataset_module(PactBroker::Dataset)
|
10
7
|
end
|
11
8
|
end
|
12
9
|
end
|
@@ -1,12 +1,8 @@
|
|
1
1
|
require "pact_broker/domain/tag"
|
2
|
-
require "pact_broker/repositories/helpers"
|
3
2
|
|
4
3
|
module PactBroker
|
5
4
|
module Tags
|
6
5
|
class Repository
|
7
|
-
|
8
|
-
include PactBroker::Repositories::Helpers
|
9
|
-
|
10
6
|
def create args
|
11
7
|
params = {
|
12
8
|
name: args.fetch(:name),
|
@@ -22,9 +18,9 @@ module PactBroker
|
|
22
18
|
.select_all_qualified
|
23
19
|
.join(:versions, { id: :version_id })
|
24
20
|
.join(:pacticipants, {Sequel.qualify("pacticipants", "id") => Sequel.qualify("versions", "pacticipant_id")})
|
25
|
-
.where(name_like(Sequel.qualify("tags", "name"), args.fetch(:tag_name)))
|
26
|
-
.where(name_like(Sequel.qualify("versions", "number"), args.fetch(:pacticipant_version_number)))
|
27
|
-
.where(name_like(Sequel.qualify("pacticipants", "name"), args.fetch(:pacticipant_name)))
|
21
|
+
.where(Sequel.name_like(Sequel.qualify("tags", "name"), args.fetch(:tag_name)))
|
22
|
+
.where(Sequel.name_like(Sequel.qualify("versions", "number"), args.fetch(:pacticipant_version_number)))
|
23
|
+
.where(Sequel.name_like(Sequel.qualify("pacticipants", "name"), args.fetch(:pacticipant_name)))
|
28
24
|
.single_record
|
29
25
|
end
|
30
26
|
|
@@ -31,6 +31,8 @@ require "pact_broker/deployments/released_version_service"
|
|
31
31
|
require "pact_broker/versions/branch_version_repository"
|
32
32
|
require "pact_broker/integrations/repository"
|
33
33
|
require "pact_broker/contracts/service"
|
34
|
+
require "pact_broker/contracts/contract_to_publish"
|
35
|
+
require "pact_broker/contracts/contracts_to_publish"
|
34
36
|
|
35
37
|
require "ostruct"
|
36
38
|
|
@@ -86,6 +88,12 @@ module PactBroker
|
|
86
88
|
self
|
87
89
|
end
|
88
90
|
|
91
|
+
# Creates a consumer, consumer version, provider and pact with the specified JSON content
|
92
|
+
# Does NOT rely on previous state.
|
93
|
+
# @param [String] consumer_name
|
94
|
+
# @param [String] consumer_version_number
|
95
|
+
# @param [Strig] provider_name
|
96
|
+
# @param [String] json_content
|
89
97
|
def create_pact_with_hierarchy consumer_name = "Consumer", consumer_version_number = "1.2.3", provider_name = "Provider", json_content = nil
|
90
98
|
use_consumer(consumer_name)
|
91
99
|
create_consumer(consumer_name) if !consumer
|
@@ -97,18 +105,39 @@ module PactBroker
|
|
97
105
|
self
|
98
106
|
end
|
99
107
|
|
108
|
+
# Creates a consumer, consumer version with tag, provider and pact
|
109
|
+
# Does NOT rely on previous state.
|
110
|
+
# @param [String] consumer_name
|
111
|
+
# @param [String] consumer_version_number
|
112
|
+
# @param [String] consumer_version_tag_name
|
113
|
+
# @param [Strig] provider_name
|
100
114
|
def create_pact_with_consumer_version_tag consumer_name, consumer_version_number, consumer_version_tag_name, provider_name
|
101
115
|
create_pact_with_hierarchy(consumer_name, consumer_version_number, provider_name)
|
102
116
|
create_consumer_version_tag(consumer_version_tag_name)
|
103
117
|
self
|
104
118
|
end
|
105
119
|
|
120
|
+
# Creates a consumer, consumer version, provider, pact and verification
|
121
|
+
# Does NOT rely on previous state.
|
122
|
+
# @param [String] consumer_name
|
123
|
+
# @param [String] consumer_version
|
124
|
+
# @param [String] provider_name
|
125
|
+
# @param [String] provider_version
|
126
|
+
# @param [Boolean] success default true
|
106
127
|
def create_pact_with_verification consumer_name = "Consumer", consumer_version = "1.0.#{model_counter}", provider_name = "Provider", provider_version = "1.0.#{model_counter}", success = true
|
107
128
|
create_pact_with_hierarchy(consumer_name, consumer_version, provider_name)
|
108
129
|
create_verification(number: model_counter, provider_version: provider_version, success: success)
|
109
130
|
self
|
110
131
|
end
|
111
132
|
|
133
|
+
# Creates a consumer, consumer version, provider, pact and verification
|
134
|
+
# Does NOT rely on previous state.
|
135
|
+
# @param [String] consumer_name
|
136
|
+
# @param [String] consumer_version
|
137
|
+
# @param [Array<String>] consumer_version_tags
|
138
|
+
# @param [String] provider_name
|
139
|
+
# @param [String] provider_version
|
140
|
+
# @param [Array<String>] provider_version_tags
|
112
141
|
def create_pact_with_verification_and_tags consumer_name = "Consumer", consumer_version = "1.0.#{model_counter}", consumer_version_tags = [], provider_name = "Provider", provider_version = "1.0.#{model_counter}", provider_version_tags = []
|
113
142
|
create_pact_with_hierarchy(consumer_name, consumer_version, provider_name)
|
114
143
|
consumer_version_tags.each do | tag |
|
@@ -118,6 +147,10 @@ module PactBroker
|
|
118
147
|
self
|
119
148
|
end
|
120
149
|
|
150
|
+
# Create a pacticipant and version
|
151
|
+
# Does NOT rely on previous state
|
152
|
+
# @param [String] pacticipant_name
|
153
|
+
# @param [String] pacticipant_version
|
121
154
|
def create_version_with_hierarchy pacticipant_name, pacticipant_version
|
122
155
|
pacticipant = pacticipant_service.create(:name => pacticipant_name)
|
123
156
|
version = PactBroker::Domain::Version.create(:number => pacticipant_version, :pacticipant => pacticipant)
|
@@ -386,6 +419,14 @@ module PactBroker
|
|
386
419
|
self
|
387
420
|
end
|
388
421
|
|
422
|
+
# @param [Hash] parameters
|
423
|
+
# @option parameters [String] :provider_version
|
424
|
+
# @option parameters [Array<String>] :tag_names
|
425
|
+
# @option parameters [String] :branch
|
426
|
+
# @option parameters [Boolean] :success
|
427
|
+
# @option parameters [Integer] :number
|
428
|
+
# @option parameters [Boolean] :wip
|
429
|
+
# @option parameters [Boolean] :test_results
|
389
430
|
def create_verification parameters = {}
|
390
431
|
# This should use the verification service. what a mess
|
391
432
|
parameters.delete(:comment)
|
@@ -493,6 +534,10 @@ module PactBroker
|
|
493
534
|
instance_variable_get("@#{instance_variable_name}")
|
494
535
|
end
|
495
536
|
|
537
|
+
def clear_now
|
538
|
+
@now = nil
|
539
|
+
end
|
540
|
+
|
496
541
|
def set_now date
|
497
542
|
@now = date.to_date
|
498
543
|
self
|
@@ -602,6 +647,10 @@ module PactBroker
|
|
602
647
|
tag = PactBroker::Domain::Tag.create(name: tag_name, version: version)
|
603
648
|
set_created_at_if_set(params[:created_at], :tags, { name: tag.name, version_id: version.id })
|
604
649
|
end
|
650
|
+
if params[:branch]
|
651
|
+
set_created_at_if_set params[:created_at], :branches, { name: params[:branch], pacticipant_id: pacticipant.id }
|
652
|
+
set_created_at_if_set params[:created_at], :branch_versions, { branch_name: params[:branch], pacticipant_id: pacticipant.id, version_id: version.id }
|
653
|
+
end
|
605
654
|
version
|
606
655
|
end
|
607
656
|
|
@@ -638,7 +687,7 @@ module PactBroker
|
|
638
687
|
if date_to_set
|
639
688
|
Sequel::Model.db[table_name].where(selector).update(date_column_name => date_to_set)
|
640
689
|
if Sequel::Model.db.schema(table_name).any?{ |col| col.first == :updated_at }
|
641
|
-
Sequel::Model.db[table_name].where(selector
|
690
|
+
Sequel::Model.db[table_name].where(selector).update(updated_at: date_to_set)
|
642
691
|
end
|
643
692
|
end
|
644
693
|
end
|
@@ -30,12 +30,13 @@ module PactBroker
|
|
30
30
|
pacticipant = pacticipant_service.find_pacticipant_by_name(params[:name])
|
31
31
|
{
|
32
32
|
csv_path: "#{base_url}/groups/#{ERB::Util.url_encode(params[:name])}.csv",
|
33
|
+
max_pacticipants: PactBroker.configuration.network_diagram_max_pacticipants,
|
33
34
|
pacticipant_name: params[:name],
|
34
35
|
repository_url: pacticipant&.repository_url,
|
35
36
|
base_url: base_url,
|
36
37
|
pacticipant: pacticipant,
|
37
38
|
details_url: "#{base_url}/pacticipants/#{ERB::Util.url_encode(params[:name])}",
|
38
|
-
network_url: "#{base_url}/pacticipants/#{ERB::Util.url_encode(params[:name])}/network"
|
39
|
+
network_url: "#{base_url}/pacticipants/#{ERB::Util.url_encode(params[:name])}/network?maxPacticipants=#{PactBroker.configuration.network_diagram_max_pacticipants}"
|
39
40
|
}.merge(overrides)
|
40
41
|
end
|
41
42
|
end
|
@@ -110,14 +110,14 @@ module PactBroker
|
|
110
110
|
|
111
111
|
def latest_consumer_version_tags
|
112
112
|
@line.consumer_version_tags
|
113
|
-
.select(&:latest)
|
113
|
+
.select(&:latest?)
|
114
114
|
.sort_by(&:created_at)
|
115
115
|
.collect{ | tag | MatrixTag.new(tag.to_hash.merge(pacticipant_name: consumer_name, version_number: consumer_version_number)) }
|
116
116
|
end
|
117
117
|
|
118
118
|
def other_consumer_version_tags
|
119
119
|
@line.consumer_version_tags
|
120
|
-
.reject(&:latest)
|
120
|
+
.reject(&:latest?)
|
121
121
|
.sort_by(&:created_at)
|
122
122
|
.collect{ | tag | MatrixTag.new(tag.to_hash.merge(pacticipant_name: consumer_name, version_number: consumer_version_number)) }
|
123
123
|
end
|
@@ -138,14 +138,14 @@ module PactBroker
|
|
138
138
|
|
139
139
|
def latest_provider_version_tags
|
140
140
|
@line.provider_version_tags
|
141
|
-
.select(&:latest)
|
141
|
+
.select(&:latest?)
|
142
142
|
.sort_by(&:created_at)
|
143
143
|
.collect{ | tag | MatrixTag.new(tag.to_hash.merge(pacticipant_name: provider_name, version_number: provider_version_number)) }
|
144
144
|
end
|
145
145
|
|
146
146
|
def other_provider_version_tags
|
147
147
|
@line.provider_version_tags
|
148
|
-
.reject(&:latest)
|
148
|
+
.reject(&:latest?)
|
149
149
|
.sort_by(&:created_at)
|
150
150
|
.collect{ | tag | MatrixTag.new(tag.to_hash.merge(pacticipant_name: provider_name, version_number: provider_version_number)) }
|
151
151
|
end
|
@@ -329,8 +329,9 @@ window.onload = function() {
|
|
329
329
|
.attr("d","M 10 0 L 10 10 L 0 5 z")
|
330
330
|
.attr("fill", "#A0A0A0");
|
331
331
|
|
332
|
+
const maxPacticipants = new URL(location).searchParams.get("maxPacticipants") || <%= max_pacticipants %>;
|
332
333
|
|
333
|
-
d3.text(
|
334
|
+
d3.text(`<%= csv_path %>?maxPacticipants=${maxPacticipants}`, "text/csv", function(unparsedData) {
|
334
335
|
var data=d3.csv.parseRows(unparsedData);
|
335
336
|
pacticipants = parseCSV(data);
|
336
337
|
pacticipantNameArray = getPacticipantNames(pacticipants);
|
@@ -2,9 +2,6 @@ require "pact_broker/domain/verification"
|
|
2
2
|
|
3
3
|
module PactBroker
|
4
4
|
module Verifications
|
5
|
-
|
6
|
-
include PactBroker::Repositories::Helpers
|
7
|
-
|
8
5
|
class LatestVerificationForConsumerAndProvider < PactBroker::Domain::Verification
|
9
6
|
set_dataset(:latest_verifications_for_consumer_and_provider)
|
10
7
|
|
data/lib/pact_broker/verifications/latest_verification_id_for_pact_version_and_provider_version.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require "pact_broker/
|
1
|
+
require "pact_broker/dataset"
|
2
2
|
|
3
3
|
module PactBroker
|
4
4
|
module Verifications
|
@@ -8,9 +8,7 @@ module PactBroker
|
|
8
8
|
|
9
9
|
plugin :upsert, identifying_columns: [:pact_version_id, :provider_version_id]
|
10
10
|
|
11
|
-
dataset_module
|
12
|
-
include PactBroker::Repositories::Helpers
|
13
|
-
end
|
11
|
+
dataset_module(PactBroker::Dataset)
|
14
12
|
end
|
15
13
|
end
|
16
14
|
end
|
@@ -1,4 +1,3 @@
|
|
1
|
-
require "sequel"
|
2
1
|
require "pact_broker/domain/verification"
|
3
2
|
require "pact_broker/verifications/sequence"
|
4
3
|
require "pact_broker/verifications/latest_verification_id_for_pact_version_and_provider_version"
|
@@ -8,8 +7,6 @@ require "pact_broker/repositories/scopes"
|
|
8
7
|
module PactBroker
|
9
8
|
module Verifications
|
10
9
|
class Repository
|
11
|
-
|
12
|
-
include PactBroker::Repositories::Helpers
|
13
10
|
include PactBroker::Repositories
|
14
11
|
include PactBroker::Repositories::Scopes
|
15
12
|
|
@@ -140,8 +137,8 @@ module PactBroker
|
|
140
137
|
consumer = pacticipant_repository.find_by_name!(consumer_name)
|
141
138
|
provider = pacticipant_repository.find_by_name!(provider_name)
|
142
139
|
|
143
|
-
consumer_tag_filter =
|
144
|
-
provider_tag_filter =
|
140
|
+
consumer_tag_filter = Sequel.name_like(Sequel.qualify(:consumer_tags, :name), consumer_version_tag)
|
141
|
+
provider_tag_filter = Sequel.name_like(Sequel.qualify(:provider_tags, :name), provider_version_tag)
|
145
142
|
|
146
143
|
query = scope_for(PactBroker::Domain::Verification)
|
147
144
|
.select_all_qualified
|
@@ -1,6 +1,3 @@
|
|
1
|
-
require "sequel"
|
2
|
-
require "pact_broker/repositories/helpers"
|
3
|
-
|
4
1
|
module PactBroker
|
5
2
|
module Verifications
|
6
3
|
class Sequence < Sequel::Model(:verification_sequence_number)
|
@@ -8,7 +5,7 @@ module PactBroker
|
|
8
5
|
# The easiest way to implement a cross database compatible sequence.
|
9
6
|
# Sad, I know.
|
10
7
|
def next_val
|
11
|
-
if PactBroker::
|
8
|
+
if PactBroker::Dataset::Helpers.postgres?
|
12
9
|
db.execute("SELECT nextval('verification_number_sequence') as val") { |v| v.first["val"].to_i }
|
13
10
|
else
|
14
11
|
db.transaction do
|
@@ -31,6 +31,10 @@ module PactBroker
|
|
31
31
|
|
32
32
|
# TODO use a decorator instead of passing in params, srsly, Beth
|
33
33
|
# verified_pacts is an array of SelectedPact objects
|
34
|
+
# @param [Integer] next_verification_number
|
35
|
+
# @param [Hash] params the verification params
|
36
|
+
# @param [Array<SelectedPact>] verified_pacts
|
37
|
+
# @param [Hash] event_context
|
34
38
|
def create next_verification_number, params, verified_pacts, event_context
|
35
39
|
first_verified_pact = verified_pacts.first
|
36
40
|
logger.info("Creating verification #{next_verification_number} for pact_version_sha=#{first_verified_pact.pact_version_sha}", params.without("testResults"))
|
data/lib/pact_broker/version.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
require "pact_broker/
|
2
|
-
require "pact_broker/repositories/helpers"
|
1
|
+
require "pact_broker/dataset"
|
3
2
|
|
4
3
|
module PactBroker
|
5
4
|
module Versions
|
@@ -11,9 +10,7 @@ module PactBroker
|
|
11
10
|
associate(:many_to_one, :pacticipant, :class => "PactBroker::Domain::Pacticipant", :key => :pacticipant_id, :primary_key => :id)
|
12
11
|
associate(:one_to_many, :branch_versions, :class => "PactBroker::Versions::BranchVersion", :key => :branch_id, :primary_key => :id)
|
13
12
|
|
14
|
-
dataset_module
|
15
|
-
include PactBroker::Repositories::Helpers
|
16
|
-
end
|
13
|
+
dataset_module(PactBroker::Dataset)
|
17
14
|
end
|
18
15
|
end
|
19
16
|
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require "pact_broker/repositories/scopes"
|
2
|
+
module PactBroker
|
3
|
+
module Versions
|
4
|
+
class BranchRepository
|
5
|
+
include PactBroker::Services
|
6
|
+
include PactBroker::Repositories::Scopes
|
7
|
+
|
8
|
+
# @param [PactBroker::Domain::Pacticipant] pacticipant
|
9
|
+
# @param [Hash] filter_options with key :query_string
|
10
|
+
# @param [Hash] pagination_options with keys :page_size and :page_number
|
11
|
+
# @param [Array] eager_load_associations the associations to eager load
|
12
|
+
def find_all_branches_for_pacticipant(pacticipant, filter_options = {}, pagination_options = {}, eager_load_associations = [])
|
13
|
+
query = scope_for(Branch).where(pacticipant_id: pacticipant.id).select_all_qualified
|
14
|
+
query = query.filter(:name, filter_options[:query_string]) if filter_options[:query_string]
|
15
|
+
query
|
16
|
+
.order(Sequel.desc(:created_at), Sequel.desc(:id))
|
17
|
+
.eager(*eager_load_associations)
|
18
|
+
.all_with_pagination_options(pagination_options)
|
19
|
+
end
|
20
|
+
|
21
|
+
# @param [String] pacticipant_name
|
22
|
+
# @param [String] branch_name
|
23
|
+
# @return [PactBroker::Versions::Branch, nil]
|
24
|
+
def find_branch(pacticipant_name:, branch_name:)
|
25
|
+
Branch
|
26
|
+
.select_all_qualified
|
27
|
+
.join(:pacticipants, { Sequel[:branches][:pacticipant_id] => Sequel[:pacticipants][:id] }) do
|
28
|
+
Sequel.name_like(Sequel[:pacticipants][:name], pacticipant_name)
|
29
|
+
end
|
30
|
+
.where(Sequel[:branches][:name] => branch_name)
|
31
|
+
.single_record
|
32
|
+
end
|
33
|
+
|
34
|
+
# Deletes a branch, its branch head and branch_version objects, without deleting the
|
35
|
+
# pacticipant version objects
|
36
|
+
#
|
37
|
+
# @param [PactBroker::Versions::Branch] the branch to delete
|
38
|
+
def delete_branch(branch)
|
39
|
+
branch.delete
|
40
|
+
end
|
41
|
+
|
42
|
+
# @param [PactBroker::Domain::Pacticipant] pacticipant
|
43
|
+
# @params [Array<String>] exclude the names of the branches to NOT delete
|
44
|
+
# @param [Integer] the number of branches that will be deleted
|
45
|
+
def count_branches_to_delete(pacticipant, exclude: )
|
46
|
+
build_query_for_pacticipant_branches(pacticipant, exclude: exclude).count
|
47
|
+
end
|
48
|
+
|
49
|
+
# Returns the list of branches which will NOT be deleted (the bulk delete is executed async after the request has finished)
|
50
|
+
# @param [PactBroker::Domain::Pacticipant] pacticipant
|
51
|
+
# @params [Array<String>] exclude the names of the branches to NOT delete
|
52
|
+
# @return [Array<PactBroker::Versions::Branch>]
|
53
|
+
def remaining_branches_after_future_deletion(pacticipant, exclude: )
|
54
|
+
exclude_dup = exclude.dup
|
55
|
+
if pacticipant.main_branch
|
56
|
+
exclude_dup << pacticipant.main_branch
|
57
|
+
end
|
58
|
+
Branch.where(pacticipant_id: pacticipant.id).where(name: exclude_dup)
|
59
|
+
end
|
60
|
+
|
61
|
+
# @param [PactBroker::Domain::Pacticipant] pacticipant
|
62
|
+
# @params [Array<String>] exclude the names of the branches to NOT delete
|
63
|
+
def delete_branches_for_pacticipant(pacticipant, exclude:)
|
64
|
+
build_query_for_pacticipant_branches(pacticipant, exclude: exclude).delete
|
65
|
+
end
|
66
|
+
|
67
|
+
def build_query_for_pacticipant_branches(pacticipant, exclude: )
|
68
|
+
exclude_dup = exclude.dup
|
69
|
+
if pacticipant.main_branch
|
70
|
+
exclude_dup << pacticipant.main_branch
|
71
|
+
end
|
72
|
+
Branch.where(pacticipant_id: pacticipant.id).exclude(name: exclude_dup)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -1,40 +1,28 @@
|
|
1
|
+
require "forwardable"
|
1
2
|
require "pact_broker/logging"
|
2
3
|
require "pact_broker/repositories"
|
3
4
|
require "pact_broker/messages"
|
4
|
-
require "forwardable"
|
5
5
|
|
6
6
|
module PactBroker
|
7
7
|
module Versions
|
8
8
|
class BranchService
|
9
9
|
extend PactBroker::Repositories
|
10
|
+
extend PactBroker::Messages
|
10
11
|
|
11
12
|
class << self
|
12
13
|
extend Forwardable
|
13
|
-
delegate [:delete_branch_version] => :branch_version_repository
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
def self.find_branch_version(pacticipant_name:, branch_name:, version_number:, **)
|
18
|
-
BranchVersion.where(
|
19
|
-
version: PactBroker::Domain::Version.where_pacticipant_name_and_version_number(pacticipant_name, version_number),
|
20
|
-
branch: Branch.where(name: branch_name)
|
21
|
-
).single_record
|
22
|
-
end
|
23
|
-
|
24
|
-
def self.find_or_create_branch_version(pacticipant_name:, branch_name:, version_number:, **)
|
25
|
-
pacticipant = pacticipant_repository.find_by_name_or_create(pacticipant_name)
|
26
|
-
version = version_repository.find_by_pacticipant_id_and_number_or_create(pacticipant.id, version_number)
|
27
|
-
branch_version_repository.add_branch(version, branch_name)
|
28
|
-
end
|
14
|
+
delegate [:find_branch_version, :find_or_create_branch_version, :delete_branch_version] => :branch_version_repository
|
15
|
+
delegate [:find_branch, :delete_branch, :find_all_branches_for_pacticipant, :delete_branches_for_pacticipant] => :branch_repository
|
29
16
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
.
|
37
|
-
.
|
17
|
+
# Returns a list of notices to display to the user in the terminal
|
18
|
+
# @param [PactBroker::Domain::Pacticipant] pacticipant
|
19
|
+
# @param [Array<String>] exclude the list of branches to NOT delete
|
20
|
+
# @return [Array<PactBroker::Contracts::Notice>]
|
21
|
+
def branch_deletion_notices(pacticipant, exclude:)
|
22
|
+
count = branch_repository.count_branches_to_delete(pacticipant, exclude: exclude)
|
23
|
+
remaining = branch_repository.remaining_branches_after_future_deletion(pacticipant, exclude: exclude).sort_by(&:created_at).collect(&:name).join(", ")
|
24
|
+
[PactBroker::Contracts::Notice.success(message("messages.branch.bulk_delete", count: count, pacticipant_name: pacticipant.name, remaining: remaining))]
|
25
|
+
end
|
38
26
|
end
|
39
27
|
end
|
40
28
|
end
|
@@ -1,7 +1,24 @@
|
|
1
|
+
require "pact_broker/versions/branch_version"
|
2
|
+
require "pact_broker/services"
|
3
|
+
|
1
4
|
module PactBroker
|
2
5
|
module Versions
|
3
6
|
class BranchVersionRepository
|
4
7
|
include PactBroker::Services
|
8
|
+
include PactBroker::Repositories
|
9
|
+
|
10
|
+
def find_branch_version(pacticipant_name:, branch_name:, version_number:, **)
|
11
|
+
BranchVersion.where(
|
12
|
+
version: PactBroker::Domain::Version.where_pacticipant_name_and_version_number(pacticipant_name, version_number),
|
13
|
+
branch: Branch.where(name: branch_name)
|
14
|
+
).single_record
|
15
|
+
end
|
16
|
+
|
17
|
+
def find_or_create_branch_version(pacticipant_name:, branch_name:, version_number:, **)
|
18
|
+
pacticipant = pacticipant_repository.find_by_name_or_create(pacticipant_name)
|
19
|
+
version = version_repository.find_by_pacticipant_id_and_number_or_create(pacticipant.id, version_number)
|
20
|
+
branch_version_repository.add_branch(version, branch_name)
|
21
|
+
end
|
5
22
|
|
6
23
|
def add_branch(version, branch_name, auto_created: false)
|
7
24
|
branch = find_or_create_branch(version.pacticipant, branch_name)
|
@@ -1,4 +1,3 @@
|
|
1
|
-
require "sequel"
|
2
1
|
require "pact_broker/logging"
|
3
2
|
require "pact_broker/domain/version"
|
4
3
|
require "pact_broker/tags/repository"
|
@@ -11,7 +10,6 @@ module PactBroker
|
|
11
10
|
class Repository
|
12
11
|
|
13
12
|
include PactBroker::Logging
|
14
|
-
include PactBroker::Repositories::Helpers
|
15
13
|
include PactBroker::Repositories
|
16
14
|
|
17
15
|
def find_by_pacticipant_id_and_number pacticipant_id, number
|
@@ -59,6 +57,9 @@ module PactBroker
|
|
59
57
|
.single_record
|
60
58
|
end
|
61
59
|
|
60
|
+
# The eager loaded relations are hardcoded here to support the PactBroker::Api::Decorators::VersionDecorator
|
61
|
+
# Newer "find all" implementations for other models pass the relations to eager load in
|
62
|
+
# from the decorator via the resource.
|
62
63
|
def find_all_pacticipant_versions_in_reverse_order name, pagination_options = {}
|
63
64
|
pacticipant = pacticipant_repository.find_by_name!(name)
|
64
65
|
query = PactBroker::Domain::Version
|
@@ -71,6 +72,22 @@ module PactBroker
|
|
71
72
|
query.all_with_pagination_options(pagination_options)
|
72
73
|
end
|
73
74
|
|
75
|
+
def find_pacticipant_versions_in_reverse_order(pacticipant_name, options = {}, pagination_options = {})
|
76
|
+
pacticipant = pacticipant_repository.find_by_name!(pacticipant_name)
|
77
|
+
query = PactBroker::Domain::Version
|
78
|
+
.where(pacticipant: pacticipant)
|
79
|
+
.eager(:pacticipant)
|
80
|
+
.eager(branch_versions: [:version, :branch_head, { branch: :pacticipant }])
|
81
|
+
.eager(tags: :head_tag)
|
82
|
+
.eager(:pact_publications)
|
83
|
+
.reverse_order(:order)
|
84
|
+
|
85
|
+
if options[:branch_name]
|
86
|
+
query = query.where_branch_name(options[:branch_name])
|
87
|
+
end
|
88
|
+
query.all_with_pagination_options(pagination_options)
|
89
|
+
end
|
90
|
+
|
74
91
|
# There may be a race condition if two simultaneous requests come in to create the same version
|
75
92
|
def create(args)
|
76
93
|
version_params = {
|
@@ -1,5 +1,3 @@
|
|
1
|
-
require "sequel"
|
2
|
-
|
3
1
|
module PactBroker
|
4
2
|
module Versions
|
5
3
|
class Sequence < Sequel::Model(:version_sequence_number)
|
@@ -8,7 +6,7 @@ module PactBroker
|
|
8
6
|
# The easiest way to implement a cross database compatible sequence.
|
9
7
|
# Sad, I know.
|
10
8
|
def next_val
|
11
|
-
if PactBroker::
|
9
|
+
if PactBroker::Dataset::Helpers.postgres?
|
12
10
|
db.execute("SELECT nextval('version_order_sequence') as val") { |v| v.first["val"].to_i }
|
13
11
|
else
|
14
12
|
db.transaction do
|
@@ -30,6 +30,10 @@ module PactBroker
|
|
30
30
|
version_repository.find_all_pacticipant_versions_in_reverse_order(name, pagination_options)
|
31
31
|
end
|
32
32
|
|
33
|
+
def self.find_pacticipant_versions_in_reverse_order(pacticipant_name, options, pagination_options = {})
|
34
|
+
version_repository.find_pacticipant_versions_in_reverse_order(pacticipant_name, options, pagination_options)
|
35
|
+
end
|
36
|
+
|
33
37
|
def self.create_or_overwrite(pacticipant_name, version_number, version)
|
34
38
|
pacticipant = pacticipant_repository.find_by_name_or_create(pacticipant_name)
|
35
39
|
version = version_repository.create_or_overwrite(pacticipant, version_number, version)
|
@@ -1,6 +1,4 @@
|
|
1
|
-
require "
|
2
|
-
require "pact_broker/db"
|
3
|
-
require "pact_broker/repositories/helpers"
|
1
|
+
require "pact_broker/dataset"
|
4
2
|
|
5
3
|
module PactBroker
|
6
4
|
module Webhooks
|
@@ -15,12 +13,10 @@ module PactBroker
|
|
15
13
|
set_primary_key :id
|
16
14
|
plugin :timestamps
|
17
15
|
|
18
|
-
dataset_module do
|
19
|
-
include PactBroker::Repositories::Helpers
|
20
|
-
end
|
21
|
-
|
22
16
|
associate(:many_to_one, :triggered_webhook, :class => "PactBroker::Webhooks::TriggeredWebhook", :key => :triggered_webhook_id, :primary_key => :id)
|
23
17
|
|
18
|
+
dataset_module(PactBroker::Dataset)
|
19
|
+
|
24
20
|
def <=> other
|
25
21
|
comp = created_date <=> other.created_date
|
26
22
|
comp = id <=> other.id if comp == 0
|