pact_broker 2.81.0 → 2.82.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +1 -1
- data/CHANGELOG.md +30 -0
- data/DEVELOPER_SETUP.md +1 -1
- data/README.md +7 -5
- data/config.ru +3 -28
- data/db/migrations/20210722_add_index_to_triggered_webhooks_webhook_uuid.rb +7 -0
- data/db/migrations/20210810_set_allow_contract_modification.rb +17 -0
- data/docs/CONFIGURATION.md +398 -0
- data/docs/configuration.yml +320 -0
- data/example/Gemfile +4 -4
- data/example/README.md +15 -22
- data/example/config.ru +1 -24
- data/example/config/pact_broker.yml +9 -0
- data/example/config/puma.rb +3 -0
- data/lib/db.rb +1 -1
- data/lib/pact_broker/api/authorization/resource_access_policy.rb +68 -0
- data/lib/pact_broker/api/authorization/resource_access_rules.rb +40 -0
- data/lib/pact_broker/api/decorators/deployed_version_decorator.rb +2 -0
- data/lib/pact_broker/api/decorators/released_version_decorator.rb +2 -0
- data/lib/pact_broker/api/middleware/basic_auth.rb +63 -0
- data/lib/pact_broker/api/resources/pact.rb +15 -6
- data/lib/pact_broker/api/resources/tag.rb +1 -14
- data/lib/pact_broker/app.rb +52 -30
- data/lib/pact_broker/config/basic_auth_configuration.rb +38 -0
- data/lib/pact_broker/config/load.rb +21 -10
- data/lib/pact_broker/config/runtime_configuration.rb +188 -0
- data/lib/pact_broker/config/runtime_configuration_coercion_methods.rb +41 -0
- data/lib/pact_broker/config/runtime_configuration_database_methods.rb +119 -0
- data/lib/pact_broker/config/runtime_configuration_logging_methods.rb +61 -0
- data/lib/pact_broker/configuration.rb +67 -131
- data/lib/pact_broker/contracts/notice.rb +4 -0
- data/lib/pact_broker/contracts/service.rb +4 -4
- data/lib/pact_broker/db/models.rb +3 -0
- data/lib/pact_broker/db/validate_encoding.rb +0 -4
- data/lib/pact_broker/deployments/deployed_version.rb +8 -2
- data/lib/pact_broker/deployments/deployed_version_service.rb +13 -6
- data/lib/pact_broker/deployments/environment.rb +1 -1
- data/lib/pact_broker/deployments/released_version.rb +8 -0
- data/lib/pact_broker/deployments/released_version_service.rb +12 -0
- data/lib/pact_broker/doc/views/provider-pacts-for-verification.markdown +4 -0
- data/lib/pact_broker/domain/pacticipant.rb +17 -13
- data/lib/pact_broker/domain/verification.rb +4 -22
- data/lib/pact_broker/domain/version.rb +9 -5
- data/lib/pact_broker/domain/webhook.rb +4 -0
- data/lib/pact_broker/error.rb +1 -0
- data/lib/pact_broker/errors.rb +1 -1
- data/lib/pact_broker/feature_toggle.rb +3 -5
- data/lib/pact_broker/hash_refinements.rb +0 -1
- data/lib/pact_broker/index/service.rb +4 -6
- data/lib/pact_broker/initializers/database_connection.rb +80 -0
- data/lib/pact_broker/integrations/integration.rb +5 -0
- data/lib/pact_broker/integrations/service.rb +4 -2
- data/lib/pact_broker/locale/en.yml +1 -0
- data/lib/pact_broker/logging.rb +2 -1
- data/lib/pact_broker/matrix/integration.rb +1 -1
- data/lib/pact_broker/matrix/parse_can_i_deploy_query.rb +2 -2
- data/lib/pact_broker/matrix/quick_row.rb +10 -0
- data/lib/pact_broker/matrix/repository.rb +64 -3
- data/lib/pact_broker/metrics/service.rb +16 -13
- data/lib/pact_broker/pacticipants/repository.rb +4 -0
- data/lib/pact_broker/pacticipants/service.rb +9 -1
- data/lib/pact_broker/pacts/pact_publication.rb +10 -13
- data/lib/pact_broker/pacts/pact_publication_dataset_module.rb +6 -1
- data/lib/pact_broker/pacts/pact_publication_selector_dataset_module.rb +1 -2
- data/lib/pact_broker/pacts/pact_version.rb +25 -11
- data/lib/pact_broker/pacts/pacts_for_verification_repository.rb +54 -77
- data/lib/pact_broker/pacts/selected_pact.rb +1 -1
- data/lib/pact_broker/pacts/selector.rb +15 -2
- data/lib/pact_broker/pacts/selectors.rb +4 -0
- data/lib/pact_broker/pacts/service.rb +4 -0
- data/lib/pact_broker/repositories/scopes.rb +12 -1
- data/lib/pact_broker/string_refinements.rb +6 -0
- data/lib/pact_broker/tags/service.rb +8 -1
- data/lib/pact_broker/test/http_test_data_builder.rb +11 -5
- data/lib/pact_broker/ui/views/index/_css_and_js.haml +11 -9
- data/lib/pact_broker/ui/views/index/_pagination.haml +3 -1
- data/lib/pact_broker/ui/views/layouts/main.haml +5 -3
- data/lib/pact_broker/ui/views/matrix/show.haml +10 -8
- data/lib/pact_broker/verifications/required_verification.rb +28 -0
- data/lib/pact_broker/verifications/service.rb +49 -1
- data/lib/pact_broker/version.rb +1 -1
- data/lib/pact_broker/versions/repository.rb +15 -0
- data/lib/pact_broker/versions/service.rb +32 -2
- data/lib/pact_broker/webhooks/event_listener.rb +3 -0
- data/lib/pact_broker/webhooks/trigger_service.rb +30 -14
- data/lib/pact_broker/webhooks/triggered_webhook.rb +1 -0
- data/lib/pact_broker/webhooks/webhook.rb +2 -2
- data/lib/pact_broker/webhooks/webhook_event.rb +6 -1
- data/lib/semantic_logger/formatters/short.rb +29 -0
- data/pact_broker.gemspec +1 -0
- data/script/data/auto-create-things-for-tags.rb +19 -0
- data/script/data/contract-published-requiring-verification.rb +27 -0
- data/script/{reproduce-issue-expand-currently-deployed.rb → data/expand-currently-deployed.rb} +0 -0
- data/script/docs/generate-configuration-docs.rb +86 -0
- data/spec/features/get_latest_pact_badge_spec.rb +1 -0
- data/spec/features/get_matrix_badge_spec.rb +1 -0
- data/spec/features/publish_pact_spec.rb +21 -7
- data/spec/features/wip_pacts_spec.rb +1 -1
- data/spec/fixtures/approvals/matrix_integration_environment_spec.approved.json +62 -0
- data/spec/fixtures/approvals/matrix_integration_ignore_spec.approved.json +124 -0
- data/spec/fixtures/approvals/matrix_integration_spec.approved.json +173 -0
- data/spec/fixtures/approvals/publish_contract_no_branch.approved.json +9 -9
- data/spec/fixtures/approvals/publish_contract_nothing_exists.approved.json +7 -7
- data/spec/fixtures/approvals/publish_contract_nothing_exists_with_webhook.approved.json +5 -5
- data/spec/fixtures/approvals/publish_contract_verification_already_exists.approved.json +5 -5
- data/spec/lib/pact_broker/api/middleware/basic_auth_spec.rb +312 -0
- data/spec/lib/pact_broker/api/resources/tag_spec.rb +14 -39
- data/spec/lib/pact_broker/app_basic_auth_spec.rb +122 -0
- data/spec/lib/pact_broker/config/load_spec.rb +33 -6
- data/spec/lib/pact_broker/config/runtime_configuration_logging_methods_spec.rb +22 -0
- data/spec/lib/pact_broker/config/runtime_configuration_spec.rb +71 -0
- data/spec/lib/pact_broker/configuration_spec.rb +51 -25
- data/spec/lib/pact_broker/errors/error_logger_spec.rb +3 -0
- data/spec/lib/pact_broker/feature_toggle_spec.rb +18 -19
- data/spec/lib/pact_broker/matrix/integration_environment_spec.rb +12 -0
- data/spec/lib/pact_broker/matrix/integration_ignore_spec.rb +15 -3
- data/spec/lib/pact_broker/matrix/integration_spec.rb +47 -6
- data/spec/lib/pact_broker/matrix/parse_can_i_deploy_query_spec.rb +16 -1
- data/spec/lib/pact_broker/matrix/repository_dependency_spec.rb +0 -2
- data/spec/lib/pact_broker/matrix/repository_spec.rb +0 -2
- data/spec/lib/pact_broker/metrics/service_spec.rb +44 -0
- data/spec/lib/pact_broker/pacticipants/service_spec.rb +28 -5
- data/spec/lib/pact_broker/pacts/pact_publication_selector_dataset_module_spec.rb +25 -0
- data/spec/lib/pact_broker/pacts/pact_version_spec.rb +30 -1
- data/spec/lib/pact_broker/pacts/repository_find_for_verification_spec.rb +107 -20
- data/spec/lib/pact_broker/pacts/verifiable_pact_messages_spec.rb +1 -1
- data/spec/lib/pact_broker/tags/service_spec.rb +24 -8
- data/spec/lib/pact_broker/verifications/service_spec.rb +146 -0
- data/spec/lib/pact_broker/versions/repository_spec.rb +38 -2
- data/spec/lib/pact_broker/versions/service_spec.rb +93 -2
- data/spec/lib/pact_broker/webhooks/trigger_service_spec.rb +54 -2
- data/spec/lib/rack/pact_broker/invalid_uri_protection_spec.rb +3 -3
- data/spec/spec_helper.rb +2 -1
- data/spec/support/approvals.rb +29 -0
- metadata +52 -13
- data/example/basic_auth/Gemfile +0 -5
- data/example/basic_auth/Procfile +0 -1
- data/example/basic_auth/README.md +0 -43
- data/example/basic_auth/config.ru +0 -19
- data/example/example_data.sql +0 -19
- data/spec/lib/pact_broker/config/save_and_load_spec.rb +0 -25
- data/spec/lib/pact_broker/pacts/service_find_for_verification_spec.rb +0 -50
@@ -1,118 +1,63 @@
|
|
1
1
|
require "pact_broker/version"
|
2
2
|
require "pact_broker/error"
|
3
|
-
require "pact_broker/config/space_delimited_string_list"
|
4
|
-
require "pact_broker/config/space_delimited_integer_list"
|
5
3
|
require "semantic_logger"
|
4
|
+
require "forwardable"
|
5
|
+
require "pact_broker/config/runtime_configuration"
|
6
|
+
require "anyway/auto_cast"
|
6
7
|
|
7
8
|
module PactBroker
|
8
|
-
|
9
|
-
class ConfigurationError < PactBroker::Error; end
|
10
|
-
|
11
9
|
def self.configuration
|
12
10
|
@@configuration ||= Configuration.default_configuration
|
13
11
|
end
|
14
12
|
|
13
|
+
def self.with_runtime_configuration_overrides(overrides, &block)
|
14
|
+
self.configuration.with_runtime_configuration_overrides(overrides, &block)
|
15
|
+
end
|
16
|
+
|
15
17
|
# @private, for testing only
|
16
18
|
def self.reset_configuration
|
17
19
|
@@configuration = Configuration.default_configuration
|
18
20
|
end
|
19
21
|
|
20
22
|
class Configuration
|
23
|
+
extend Forwardable
|
24
|
+
|
25
|
+
delegate PactBroker::Config::RuntimeConfiguration.getter_and_setter_method_names => :runtime_configuration
|
21
26
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
:enable_public_badge_access,
|
26
|
-
:shields_io_base_url,
|
27
|
-
:check_for_potential_duplicate_pacticipant_names,
|
28
|
-
:webhook_retry_schedule,
|
29
|
-
:semver_formats,
|
30
|
-
:disable_ssl_verification,
|
31
|
-
:webhook_http_method_whitelist,
|
32
|
-
:webhook_scheme_whitelist,
|
33
|
-
:webhook_host_whitelist,
|
34
|
-
:webhook_http_code_success,
|
35
|
-
:base_equality_only_on_content_that_affects_verification_results,
|
36
|
-
:seed_example_data,
|
37
|
-
:badge_provider_mode,
|
38
|
-
:warning_error_class_names,
|
39
|
-
:base_url,
|
40
|
-
:log_dir,
|
41
|
-
:allow_missing_migration_files,
|
42
|
-
:auto_migrate_db_data,
|
43
|
-
:use_rack_protection,
|
44
|
-
:metrics_sql_statement_timeout,
|
45
|
-
:create_deployed_versions_for_tags
|
46
|
-
]
|
47
|
-
|
48
|
-
attr_accessor :base_url, :log_dir, :database_connection, :auto_migrate_db, :auto_migrate_db_data, :allow_missing_migration_files, :example_data_seeder, :seed_example_data, :use_hal_browser, :html_pact_renderer, :use_rack_protection
|
49
|
-
attr_accessor :validate_database_connection_config, :enable_diagnostic_endpoints, :version_parser, :sha_generator
|
50
|
-
attr_accessor :use_case_sensitive_resource_names, :order_versions_by_date
|
51
|
-
attr_accessor :warning_error_class_names
|
52
|
-
attr_accessor :check_for_potential_duplicate_pacticipant_names
|
53
|
-
attr_accessor :webhook_retry_schedule
|
54
|
-
attr_accessor :user_agent
|
55
|
-
attr_reader :webhook_http_method_whitelist, :webhook_scheme_whitelist, :webhook_host_whitelist, :webhook_http_code_success
|
56
|
-
attr_accessor :semver_formats
|
57
|
-
attr_accessor :enable_public_badge_access, :shields_io_base_url, :badge_provider_mode
|
58
|
-
attr_accessor :disable_ssl_verification
|
27
|
+
attr_accessor :database_connection
|
28
|
+
attr_accessor :example_data_seeder
|
29
|
+
attr_accessor :html_pact_renderer, :version_parser, :sha_generator
|
59
30
|
attr_accessor :content_security_policy, :hal_browser_content_security_policy_overrides
|
60
|
-
attr_accessor :
|
61
|
-
attr_reader :api_error_reporters
|
31
|
+
attr_accessor :api_error_reporters
|
62
32
|
attr_reader :custom_logger
|
63
33
|
attr_accessor :policy_builder, :policy_scope_builder, :base_resource_class_factory
|
64
|
-
attr_accessor :metrics_sql_statement_timeout
|
65
|
-
attr_accessor :create_deployed_versions_for_tags
|
66
|
-
|
67
34
|
alias_method :policy_finder=, :policy_builder=
|
68
35
|
alias_method :policy_scope_finder=, :policy_scope_builder=
|
69
36
|
|
37
|
+
attr_accessor :runtime_configuration
|
38
|
+
|
70
39
|
def initialize
|
40
|
+
@runtime_configuration = PactBroker::Config::RuntimeConfiguration.new
|
71
41
|
@before_resource_hook = ->(resource){}
|
72
42
|
@after_resource_hook = ->(resource){}
|
73
43
|
@authenticate_with_basic_auth = nil
|
74
44
|
@authorize = nil
|
75
45
|
@api_error_reporters = []
|
76
|
-
@semantic_logger = SemanticLogger["root"]
|
77
46
|
end
|
78
47
|
|
79
|
-
# rubocop: disable Metrics/MethodLength
|
80
48
|
def self.default_configuration
|
81
49
|
require "pact_broker/versions/parse_semantic_version"
|
82
50
|
require "pact_broker/pacts/generate_sha"
|
83
51
|
|
84
52
|
config = Configuration.new
|
85
|
-
config.log_dir = File.expand_path("./log")
|
86
|
-
config.auto_migrate_db = true
|
87
|
-
config.auto_migrate_db_data = true
|
88
|
-
config.allow_missing_migration_files = false
|
89
|
-
config.use_rack_protection = true
|
90
|
-
config.use_hal_browser = true
|
91
|
-
config.validate_database_connection_config = true
|
92
|
-
config.enable_diagnostic_endpoints = true
|
93
|
-
config.enable_public_badge_access = false # For security
|
94
|
-
config.shields_io_base_url = "https://img.shields.io".freeze
|
95
|
-
config.badge_provider_mode = :proxy # other option is :redirect
|
96
|
-
config.use_case_sensitive_resource_names = true
|
97
53
|
config.html_pact_renderer = default_html_pact_render
|
98
54
|
config.version_parser = PactBroker::Versions::ParseSemanticVersion
|
99
55
|
config.sha_generator = PactBroker::Pacts::GenerateSha
|
100
|
-
config.seed_example_data = true
|
101
56
|
config.example_data_seeder = lambda do
|
102
57
|
require "pact_broker/db/seed_example_data"
|
103
58
|
PactBroker::DB::SeedExampleData.call
|
104
59
|
end
|
105
|
-
|
106
|
-
config.base_equality_only_on_content_that_affects_verification_results = true
|
107
|
-
config.order_versions_by_date = true
|
108
|
-
config.semver_formats = ["%M.%m.%p%s%d", "%M.%m", "%M"]
|
109
|
-
config.webhook_retry_schedule = [10, 60, 120, 300, 600, 1200] #10 sec, 1 min, 2 min, 5 min, 10 min, 20 min => 38 minutes
|
110
|
-
config.check_for_potential_duplicate_pacticipant_names = true
|
111
|
-
config.disable_ssl_verification = false
|
112
|
-
config.webhook_http_method_whitelist = ["POST"]
|
113
|
-
config.webhook_http_code_success = [200, 201, 202, 203, 204, 205, 206]
|
114
|
-
config.webhook_scheme_whitelist = ["https"]
|
115
|
-
config.webhook_host_whitelist = []
|
60
|
+
|
116
61
|
# TODO get rid of unsafe-inline
|
117
62
|
config.content_security_policy = {
|
118
63
|
script_src: "'self' 'unsafe-inline'",
|
@@ -133,25 +78,49 @@ module PactBroker
|
|
133
78
|
require "pact_broker/api/resources/default_base_resource"
|
134
79
|
PactBroker::Api::Resources::DefaultBaseResource
|
135
80
|
}
|
136
|
-
config.warning_error_class_names = ["Sequel::ForeignKeyConstraintViolation", "PG::QueryCanceled"]
|
137
|
-
config.metrics_sql_statement_timeout = 30
|
138
|
-
config.create_deployed_versions_for_tags = true
|
139
81
|
config
|
140
82
|
end
|
141
|
-
|
83
|
+
|
84
|
+
def with_runtime_configuration_overrides(overrides)
|
85
|
+
original_runtime_configuration = runtime_configuration
|
86
|
+
self.runtime_configuration = override_runtime_configuration(overrides, original_runtime_configuration.dup)
|
87
|
+
yield
|
88
|
+
ensure
|
89
|
+
self.runtime_configuration = original_runtime_configuration
|
90
|
+
end
|
91
|
+
|
92
|
+
def logger_from_runtime_configuration
|
93
|
+
@logger_from_runtime_configuration ||= begin
|
94
|
+
runtime_configuration.validate_logging_attributes!
|
95
|
+
SemanticLogger.default_level = runtime_configuration.log_level
|
96
|
+
if runtime_configuration.log_stream == :file
|
97
|
+
path = runtime_configuration.log_dir + "/pact_broker.log"
|
98
|
+
FileUtils.mkdir_p(runtime_configuration.log_dir)
|
99
|
+
@default_appender = SemanticLogger.add_appender(file_name: path, formatter: runtime_configuration.log_format)
|
100
|
+
else
|
101
|
+
@default_appender = SemanticLogger.add_appender(io: $stdout, formatter: runtime_configuration.log_format)
|
102
|
+
end
|
103
|
+
@logger_from_runtime_configuration = SemanticLogger["pact-broker"]
|
104
|
+
end
|
105
|
+
end
|
142
106
|
|
143
107
|
def logger
|
144
|
-
custom_logger ||
|
108
|
+
custom_logger || logger_from_runtime_configuration
|
145
109
|
end
|
146
110
|
|
147
111
|
def logger= logger
|
112
|
+
if @default_appender && SemanticLogger.appenders.include?(@default_appender)
|
113
|
+
SemanticLogger.remove_appender(@default_appender)
|
114
|
+
@default_appender = nil
|
115
|
+
end
|
148
116
|
@custom_logger = logger
|
149
117
|
end
|
150
118
|
|
151
119
|
def log_configuration
|
152
|
-
|
153
|
-
|
154
|
-
|
120
|
+
logger.info "------------------------------------------------------------------------"
|
121
|
+
logger.info "PACT BROKER CONFIGURATION:"
|
122
|
+
runtime_configuration.log_configuration(logger)
|
123
|
+
logger.info "------------------------------------------------------------------------"
|
155
124
|
end
|
156
125
|
|
157
126
|
def self.default_html_pact_render
|
@@ -232,68 +201,35 @@ module PactBroker
|
|
232
201
|
self.enable_public_badge_access = enable_badge_resources
|
233
202
|
end
|
234
203
|
|
235
|
-
def save_to_database
|
236
|
-
# Can't require a Sequel::Model class before the connection has been set
|
237
|
-
require "pact_broker/config/save"
|
238
|
-
PactBroker::Config::Save.call(self, SAVABLE_SETTING_NAMES)
|
239
|
-
end
|
240
|
-
|
241
204
|
def load_from_database!
|
242
205
|
# Can't require a Sequel::Model class before the connection has been set
|
243
206
|
require "pact_broker/config/load"
|
244
|
-
PactBroker::Config::Load.call(
|
207
|
+
PactBroker::Config::Load.call(runtime_configuration)
|
245
208
|
end
|
246
209
|
|
247
|
-
|
248
|
-
@webhook_http_method_whitelist = parse_space_delimited_string_list_property("webhook_http_method_whitelist", webhook_http_method_whitelist)
|
249
|
-
end
|
250
|
-
|
251
|
-
def webhook_http_code_success= webhook_http_code_success
|
252
|
-
@webhook_http_code_success = parse_space_delimited_integer_list_property("webhook_http_code_success", webhook_http_code_success)
|
253
|
-
end
|
254
|
-
|
255
|
-
def webhook_scheme_whitelist= webhook_scheme_whitelist
|
256
|
-
@webhook_scheme_whitelist = parse_space_delimited_string_list_property("webhook_scheme_whitelist", webhook_scheme_whitelist)
|
257
|
-
end
|
258
|
-
|
259
|
-
def webhook_host_whitelist= webhook_host_whitelist
|
260
|
-
@webhook_host_whitelist = parse_space_delimited_string_list_property("webhook_host_whitelist", webhook_host_whitelist)
|
261
|
-
end
|
210
|
+
private
|
262
211
|
|
263
|
-
def
|
264
|
-
|
265
|
-
|
212
|
+
def override_runtime_configuration(overrides, new_runtime_configuration)
|
213
|
+
valid_overrides = {}
|
214
|
+
invalid_overrides = {}
|
266
215
|
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
logger.warn("Class #{class_name} couldn't be loaded as a warning error class (#{e.class} - #{e.message}). Ignoring.")
|
273
|
-
nil
|
216
|
+
overrides.each do | key, value |
|
217
|
+
if new_runtime_configuration.respond_to?("#{key}=")
|
218
|
+
valid_overrides[key] = Anyway::AutoCast.call(value)
|
219
|
+
else
|
220
|
+
invalid_overrides[key] = Anyway::AutoCast.call(value)
|
274
221
|
end
|
275
|
-
end
|
276
|
-
end
|
277
|
-
|
278
|
-
private
|
222
|
+
end
|
279
223
|
|
280
|
-
|
281
|
-
|
282
|
-
when String then Config::SpaceDelimitedStringList.parse(property_value)
|
283
|
-
when Array then Config::SpaceDelimitedStringList.new(property_value)
|
284
|
-
else
|
285
|
-
raise ConfigurationError.new("Pact Broker configuration property `#{property_name}` must be a space delimited String or an Array")
|
224
|
+
if logger.debug?
|
225
|
+
logger.debug("Overridding runtime configuration", payload: { overrides: valid_overrides, ignoring: invalid_overrides })
|
286
226
|
end
|
287
|
-
end
|
288
227
|
|
289
|
-
|
290
|
-
|
291
|
-
when String then Config::SpaceDelimitedIntegerList.parse(property_value)
|
292
|
-
when Array then Config::SpaceDelimitedIntegerList.new(property_value)
|
293
|
-
else
|
294
|
-
raise ConfigurationError.new("Pact Broker configuration property `#{property_name}` must be a space delimited String or an Array with Integer values")
|
228
|
+
valid_overrides.each do | key, value |
|
229
|
+
new_runtime_configuration.public_send("#{key}=", value)
|
295
230
|
end
|
296
|
-
end
|
297
231
|
|
232
|
+
new_runtime_configuration
|
233
|
+
end
|
298
234
|
end
|
299
235
|
end
|
@@ -129,7 +129,7 @@ module PactBroker
|
|
129
129
|
message_params[:action] = existing_version ? "Updated" : "Created"
|
130
130
|
notices << Notice.debug(message(message_key_for_version_creation(parsed_contracts), message_params))
|
131
131
|
if parsed_contracts.branch.nil?
|
132
|
-
notices << Notice.
|
132
|
+
notices << Notice.prompt(" Next steps:\n " + message("messages.next_steps.version_branch"))
|
133
133
|
end
|
134
134
|
notices
|
135
135
|
end
|
@@ -217,15 +217,15 @@ module PactBroker
|
|
217
217
|
def next_steps_notices(pact)
|
218
218
|
notices = []
|
219
219
|
if !verification_service.any_verifications?(pact.consumer, pact.provider)
|
220
|
-
notices << Notice.
|
220
|
+
notices << Notice.prompt(" * " + message("messages.next_steps.verifications", provider_name: pact.provider_name))
|
221
221
|
end
|
222
222
|
|
223
223
|
if !webhook_service.any_webhooks_configured_for_pact?(pact)
|
224
|
-
notices << Notice.
|
224
|
+
notices << Notice.prompt(" * " + message("messages.next_steps.webhooks", provider_name: pact.provider_name))
|
225
225
|
end
|
226
226
|
|
227
227
|
if notices.any?
|
228
|
-
notices.unshift(Notice.
|
228
|
+
notices.unshift(Notice.prompt(" Next steps:"))
|
229
229
|
end
|
230
230
|
|
231
231
|
notices
|
@@ -3,6 +3,7 @@ require "pact_broker/webhooks/triggered_webhook"
|
|
3
3
|
require "pact_broker/webhooks/webhook"
|
4
4
|
require "pact_broker/pacts/latest_pact_publication_id_for_consumer_version"
|
5
5
|
require "pact_broker/verifications/latest_verification_id_for_pact_version_and_provider_version"
|
6
|
+
require "pact_broker/integrations/integration"
|
6
7
|
require "pact_broker/pacts/pact_publication"
|
7
8
|
require "pact_broker/pacts/pact_version"
|
8
9
|
require "pact_broker/domain/verification"
|
@@ -13,6 +14,8 @@ require "pact_broker/domain/pacticipant"
|
|
13
14
|
require "pact_broker/deployments/environment"
|
14
15
|
require "pact_broker/deployments/deployed_version"
|
15
16
|
require "pact_broker/deployments/released_version"
|
17
|
+
require "pact_broker/matrix/row"
|
18
|
+
require "pact_broker/matrix/head_row"
|
16
19
|
|
17
20
|
module PactBroker
|
18
21
|
INTEGRATIONS_TABLES = [
|
@@ -3,11 +3,8 @@ require "pact_broker/messages"
|
|
3
3
|
|
4
4
|
module PactBroker
|
5
5
|
module DB
|
6
|
-
|
7
6
|
class ConnectionConfigurationError < StandardError; end
|
8
|
-
|
9
7
|
class ValidateEncoding
|
10
|
-
|
11
8
|
extend PactBroker::Messages
|
12
9
|
|
13
10
|
def self.call connection
|
@@ -16,7 +13,6 @@ module PactBroker
|
|
16
13
|
raise ConnectionConfigurationError.new(message("errors.validation.connection_encoding_not_utf8", encoding: encoding.inspect))
|
17
14
|
end
|
18
15
|
end
|
19
|
-
|
20
16
|
end
|
21
17
|
end
|
22
18
|
end
|
@@ -4,6 +4,7 @@ require "pact_broker/deployments/currently_deployed_version_id"
|
|
4
4
|
module PactBroker
|
5
5
|
module Deployments
|
6
6
|
class DeployedVersion < Sequel::Model
|
7
|
+
many_to_one :pacticipant, :class => "PactBroker::Domain::Pacticipant", :key => :pacticipant_id, :primary_key => :id
|
7
8
|
many_to_one :version, :class => "PactBroker::Domain::Version", :key => :version_id, :primary_key => :id
|
8
9
|
many_to_one :environment, :class => "PactBroker::Deployments::Environment", :key => :environment_id, :primary_key => :id
|
9
10
|
one_to_one :currently_deployed_version_id, :class => "PactBroker::Deployments::CurrentlyDeployedVersionId", key: :deployed_version_id, primary_key: :id
|
@@ -87,10 +88,15 @@ module PactBroker
|
|
87
88
|
version.number
|
88
89
|
end
|
89
90
|
|
91
|
+
def environment_name
|
92
|
+
environment.name
|
93
|
+
end
|
94
|
+
|
90
95
|
def record_undeployed
|
91
96
|
self.class.where(id: id).record_undeployed
|
92
97
|
self.refresh
|
93
98
|
end
|
99
|
+
|
94
100
|
end
|
95
101
|
end
|
96
102
|
end
|
@@ -102,11 +108,11 @@ end
|
|
102
108
|
# version_id | integer | NOT NULL
|
103
109
|
# pacticipant_id | integer | NOT NULL
|
104
110
|
# environment_id | integer | NOT NULL
|
105
|
-
# target | text |
|
106
|
-
# target_for_index | text | NOT NULL DEFAULT ''::text
|
107
111
|
# created_at | timestamp without time zone | NOT NULL
|
108
112
|
# updated_at | timestamp without time zone | NOT NULL
|
109
113
|
# undeployed_at | timestamp without time zone |
|
114
|
+
# target | text |
|
115
|
+
# target_for_index | text | NOT NULL DEFAULT ''::text
|
110
116
|
# Indexes:
|
111
117
|
# deployed_versions_pkey | PRIMARY KEY btree (id)
|
112
118
|
# deployed_versions_uuid_index | UNIQUE btree (uuid)
|
@@ -1,8 +1,12 @@
|
|
1
1
|
require "pact_broker/deployments/deployed_version"
|
2
|
+
require "pact_broker/repositories/scopes"
|
2
3
|
|
3
4
|
module PactBroker
|
4
5
|
module Deployments
|
5
6
|
class DeployedVersionService
|
7
|
+
include PactBroker::Logging
|
8
|
+
extend PactBroker::Repositories::Scopes
|
9
|
+
extend PactBroker::Services
|
6
10
|
|
7
11
|
def self.next_uuid
|
8
12
|
SecureRandom.uuid
|
@@ -68,6 +72,15 @@ module PactBroker
|
|
68
72
|
deployed_version.record_undeployed
|
69
73
|
end
|
70
74
|
|
75
|
+
def self.maybe_create_deployed_version_for_tag(version, environment_name)
|
76
|
+
if PactBroker.configuration.create_deployed_versions_for_tags
|
77
|
+
if (environment = environment_service.find_by_name(environment_name))
|
78
|
+
logger.info("Creating deployed version for #{version.pacticipant.name} version #{version.number} in environment #{environment_name} (because create_deployed_versions_for_tags=true)")
|
79
|
+
find_or_create(next_uuid, version, environment, nil)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
71
84
|
def self.record_previous_version_undeployed(pacticipant, environment, target)
|
72
85
|
DeployedVersion.where(
|
73
86
|
undeployed_at: nil,
|
@@ -78,12 +91,6 @@ module PactBroker
|
|
78
91
|
end
|
79
92
|
|
80
93
|
private_class_method :record_previous_version_undeployed
|
81
|
-
|
82
|
-
def self.scope_for(scope)
|
83
|
-
PactBroker.policy_scope!(scope)
|
84
|
-
end
|
85
|
-
|
86
|
-
private_class_method :scope_for
|
87
94
|
end
|
88
95
|
end
|
89
96
|
end
|
@@ -44,6 +44,6 @@ end
|
|
44
44
|
# environments_name_index | UNIQUE btree (name)
|
45
45
|
# environments_uuid_index | UNIQUE btree (uuid)
|
46
46
|
# Referenced By:
|
47
|
-
# deployed_versions | deployed_versions_environment_id_fkey | (environment_id) REFERENCES environments(id)
|
48
47
|
# currently_deployed_version_ids | currently_deployed_version_ids_environment_id_fkey | (environment_id) REFERENCES environments(id) ON DELETE CASCADE
|
48
|
+
# deployed_versions | deployed_versions_environment_id_fkey | (environment_id) REFERENCES environments(id)
|
49
49
|
# released_versions | released_versions_environment_id_fkey | (environment_id) REFERENCES environments(id)
|