Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

migrate config to v5 #1560

Merged
merged 2 commits into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion node/config/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var log = logging.Logger("cfg")

// CurrentVersion is the config version expected by Boost.
// We need to migrate the config file to this version.
const CurrentVersion = 4
const CurrentVersion = 5

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

Expand All @@ -24,6 +24,7 @@ var migrations = []migrateUpFn{
v1Tov2, // index 1 => version 2
v2Tov3, // index 2 => version 3
v3Tov4, // index 3 => version 4
v4Tov5, // index 4 => version 5
}

// This struct is used to get the config file version
Expand Down
28 changes: 28 additions & 0 deletions node/config/v4_to_v5.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package config

import (
"fmt"
)

// Migrate from config version 4 to version 5
func v4Tov5(cfgPath string) (string, error) {
cfg, err := FromFile(cfgPath, DefaultBoost())
if err != nil {
return "", fmt.Errorf("parsing config file %s: %w", cfgPath, err)
}

boostCfg, ok := cfg.(*Boost)
if !ok {
return "", fmt.Errorf("unexpected config type %T: expected *config.Boost", cfg)
}

// Update the Boost config version
boostCfg.ConfigVersion = 5

bz, err := ConfigUpdate(boostCfg, DefaultBoost(), true, false)
if err != nil {
return "", fmt.Errorf("applying configuration: %w", err)
}

return string(bz), nil
}