Co-authored-by: Tom <54514587+GAtom22@users.noreply.github.com> Co-authored-by: Julien Robert <julien@rbrt.fr>
This commit is contained in:
parent
f7ee7006f1
commit
7306552f44
@ -31,6 +31,10 @@ Ref: https://keepachangelog.com/en/1.0.0/
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## [v0.1.2](https://github.com/cosmos/cosmos-sdk/releases/tag/tools/confix/v0.1.2) - 2024-08-13
|
||||
|
||||
* (confix) [#21202](https://github.com/cosmos/cosmos-sdk/pull/21202) Allow customization of migration `PlanBuilder`.
|
||||
|
||||
## [v0.1.1](https://github.com/cosmos/cosmos-sdk/releases/tag/tools/confix/v0.1.1) - 2023-12-11
|
||||
|
||||
* [#18496](https://github.com/cosmos/cosmos-sdk/pull/18496) Remove invalid non SDK config from app.toml migration templates.
|
||||
|
||||
@ -19,20 +19,28 @@ const (
|
||||
// MigrationMap defines a mapping from a version to a transformation plan.
|
||||
type MigrationMap map[string]func(from *tomledit.Document, to string) transform.Plan
|
||||
|
||||
// loadDestConfigFile is the function signature to load the destination version
|
||||
// configuration toml file.
|
||||
type loadDestConfigFile func(to string) (*tomledit.Document, error)
|
||||
|
||||
var Migrations = MigrationMap{
|
||||
"v0.45": NoPlan, // Confix supports only the current supported SDK version. So we do not support v0.44 -> v0.45.
|
||||
"v0.46": PlanBuilder,
|
||||
"v0.47": PlanBuilder,
|
||||
"v0.50": PlanBuilder,
|
||||
"v0.46": defaultPlanBuilder,
|
||||
"v0.47": defaultPlanBuilder,
|
||||
"v0.50": defaultPlanBuilder,
|
||||
// "v0.xx.x": PlanBuilder, // add specific migration in case of configuration changes in minor versions
|
||||
}
|
||||
|
||||
func defaultPlanBuilder(from *tomledit.Document, to string) transform.Plan {
|
||||
return PlanBuilder(from, to, LoadLocalConfig)
|
||||
}
|
||||
|
||||
// PlanBuilder is a function that returns a transformation plan for a given diff between two files.
|
||||
func PlanBuilder(from *tomledit.Document, to string) transform.Plan {
|
||||
func PlanBuilder(from *tomledit.Document, to string, loadFn loadDestConfigFile) transform.Plan {
|
||||
plan := transform.Plan{}
|
||||
deletedSections := map[string]bool{}
|
||||
|
||||
target, err := LoadLocalConfig(to)
|
||||
target, err := loadFn(to)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("failed to parse file: %w. This file should have been valid", err))
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user