Skip to content

Commit 540b41b

Browse files
authored
migrate config to v5 (#1560)
* migrate config to v5 * change default version
1 parent 5d903fa commit 540b41b

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

node/config/migrate.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ var log = logging.Logger("cfg")
1515

1616
// CurrentVersion is the config version expected by Boost.
1717
// We need to migrate the config file to this version.
18-
const CurrentVersion = 4
18+
const CurrentVersion = 5
1919

2020
type migrateUpFn = func(cfgPath string) (string, error)
2121

@@ -24,6 +24,7 @@ var migrations = []migrateUpFn{
2424
v1Tov2, // index 1 => version 2
2525
v2Tov3, // index 2 => version 3
2626
v3Tov4, // index 3 => version 4
27+
v4Tov5, // index 4 => version 5
2728
}
2829

2930
// This struct is used to get the config file version

node/config/v4_to_v5.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package config
2+
3+
import (
4+
"fmt"
5+
)
6+
7+
// Migrate from config version 4 to version 5
8+
func v4Tov5(cfgPath string) (string, error) {
9+
cfg, err := FromFile(cfgPath, DefaultBoost())
10+
if err != nil {
11+
return "", fmt.Errorf("parsing config file %s: %w", cfgPath, err)
12+
}
13+
14+
boostCfg, ok := cfg.(*Boost)
15+
if !ok {
16+
return "", fmt.Errorf("unexpected config type %T: expected *config.Boost", cfg)
17+
}
18+
19+
// Update the Boost config version
20+
boostCfg.ConfigVersion = 5
21+
22+
bz, err := ConfigUpdate(boostCfg, DefaultBoost(), true, false)
23+
if err != nil {
24+
return "", fmt.Errorf("applying configuration: %w", err)
25+
}
26+
27+
return string(bz), nil
28+
}

0 commit comments

Comments
 (0)