Skip to content

Commit

Permalink
feat: default allow_dangerous_contract_modification to false for new …
Browse files Browse the repository at this point in the history
…installations
  • Loading branch information
bethesque committed Jun 22, 2022
1 parent 6b2c76b commit 85a8995
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
require_relative "migration_helper"
include PactBroker::MigrationHelper

Sequel.migration do
up do
# Need to do this again because didn't actually set default of allow_dangerous_contract_modification to true
# when the first migration was run in db/migrations/20210810_set_allow_contract_modification.rb
for_upgrades_of_existing_installations do
from(:config).insert_ignore.insert(
name: "allow_dangerous_contract_modification",
type: "boolean",
value: "1",
created_at: Sequel.datetime_class.now,
updated_at: Sequel.datetime_class.now
)
end
end

down do

end
end
6 changes: 6 additions & 0 deletions db/migrations/migration_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ module MigrationHelper

extend self

def for_upgrades_of_existing_installations
if from(:integrations).count > 0
yield
end
end

def large_text_type
if postgres?
:text
Expand Down
2 changes: 1 addition & 1 deletion docs/CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ with a unique version number.
**Supported versions:** From v2.82.0<br/>
**Environment variable name:** `PACT_BROKER_ALLOW_DANGEROUS_CONTRACT_MODIFICATION`<br/>
**YAML configuration key name:** `allow_dangerous_contract_modification`<br/>
**Default:** For new installations of v2.82.0 and later, this defaults to `false`.<br/>
**Default:** For new installations of v2.102 and later, this defaults to `false` (the recommended value). Previous installations will have the default value of `true` (not recommended).<br/>
**Allowed values:** `true`, `false`<br/>
**More information:** https://docs.pact.io/versioning<br/>

Expand Down
2 changes: 1 addition & 1 deletion docs/configuration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ groups:
Whether or not to allow the pact content for an existing consumer version to be modified. It is strongly recommended that this is set to false,
as allowing modification makes the results of can-i-deploy unreliable. When this is set to false as recommended, each commit must publish pacts
with a unique version number.
default_description: For new installations of v2.82.0 and later, this defaults to `false`.
default_description: For new installations of v2.102 and later, this defaults to `false` (the recommended value). Previous installations will have the default value of `true` (not recommended).
supported_versions: From v2.82.0
allowed_values:
- true
Expand Down
2 changes: 1 addition & 1 deletion lib/pact_broker/config/runtime_configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class RuntimeConfiguration < Anyway::Config
use_first_tag_as_branch_time_limit: 10,
auto_detect_main_branch: true,
main_branch_candidates: ["develop", "main", "master"],
allow_dangerous_contract_modification: true,
allow_dangerous_contract_modification: false,
semver_formats: ["%M.%m.%p%s%d", "%M.%m", "%M"],
seed_example_data: true,
features: []
Expand Down

0 comments on commit 85a8995

Please sign in to comment.