mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-05-06 08:15:48 -04:00
cli: update config migration to migrate v3 -> v4 (#2166)
This commit is contained in:
parent
d1ace13713
commit
15bb9588d7
4 changed files with 498 additions and 8 deletions
|
@ -10,6 +10,7 @@ import (
|
|||
"fmt"
|
||||
|
||||
"github.com/edgelesssys/constellation/v2/internal/config"
|
||||
"github.com/edgelesssys/constellation/v2/internal/config/migration"
|
||||
"github.com/edgelesssys/constellation/v2/internal/constants"
|
||||
"github.com/edgelesssys/constellation/v2/internal/file"
|
||||
"github.com/spf13/afero"
|
||||
|
@ -33,7 +34,7 @@ func runConfigMigrate(cmd *cobra.Command, _ []string) error {
|
|||
}
|
||||
|
||||
func configMigrate(cmd *cobra.Command, handler file.Handler) error {
|
||||
// Make sure we are reading a v2 config
|
||||
// Make sure we are reading a v3 config
|
||||
var cfgVersion struct {
|
||||
Version string `yaml:"version"`
|
||||
}
|
||||
|
@ -41,11 +42,16 @@ func configMigrate(cmd *cobra.Command, handler file.Handler) error {
|
|||
return err
|
||||
}
|
||||
|
||||
// TODO(malt3): add migration from v3 to v4
|
||||
switch cfgVersion.Version {
|
||||
case config.Version4:
|
||||
cmd.Printf("Config already at version %s, nothing to do\n", config.Version4)
|
||||
return nil
|
||||
case migration.Version3:
|
||||
if err := migration.V3ToV4(constants.ConfigFilename, handler); err != nil {
|
||||
return fmt.Errorf("migrating config: %w", err)
|
||||
}
|
||||
cmd.Printf("Successfully migrated config to %s\n", config.Version4)
|
||||
return nil
|
||||
default:
|
||||
return fmt.Errorf("cannot convert config version %s to %s", cfgVersion.Version, config.Version4)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue