@@ -19,20 +19,28 @@ const (
1919// MigrationMap defines a mapping from a version to a transformation plan.
2020type MigrationMap map [string ]func (from * tomledit.Document , to string ) transform.Plan
2121
22+ // loadDestConfigFile is the function signature to load the destination version
23+ // configuration toml file.
24+ type loadDestConfigFile func (to string ) (* tomledit.Document , error )
25+
2226var Migrations = MigrationMap {
2327 "v0.45" : NoPlan , // Confix supports only the current supported SDK version. So we do not support v0.44 -> v0.45.
24- "v0.46" : PlanBuilder ,
25- "v0.47" : PlanBuilder ,
26- "v0.50" : PlanBuilder ,
28+ "v0.46" : defaultPlanBuilder ,
29+ "v0.47" : defaultPlanBuilder ,
30+ "v0.50" : defaultPlanBuilder ,
2731 // "v0.xx.x": PlanBuilder, // add specific migration in case of configuration changes in minor versions
2832}
2933
34+ func defaultPlanBuilder (from * tomledit.Document , to string ) transform.Plan {
35+ return PlanBuilder (from , to , LoadLocalConfig )
36+ }
37+
3038// PlanBuilder is a function that returns a transformation plan for a given diff between two files.
31- func PlanBuilder (from * tomledit.Document , to string ) transform.Plan {
39+ func PlanBuilder (from * tomledit.Document , to string , loadFn loadDestConfigFile ) transform.Plan {
3240 plan := transform.Plan {}
3341 deletedSections := map [string ]bool {}
3442
35- target , err := LoadLocalConfig (to )
43+ target , err := loadFn (to )
3644 if err != nil {
3745 panic (fmt .Errorf ("failed to parse file: %w. This file should have been valid" , err ))
3846 }
0 commit comments