1 parent
7e221e8f57
commit
3d5c94e552
4 files changed
+88
-1
No files matched your search
@@ -149,6 +149,10 @@ func PlanLegacyMigration(root string, _ RuntimeValidationOptions) (LegacyMigrati
|
||||
return plan, nil
|
||||
}
|
||||
func MigrateLegacyConfig(root string, options RuntimeValidationOptions) (LegacyMigrationResult, error) {
|
||||
return migrateLegacyConfig(root, options, false)
|
||||
}
|
||||
|
||||
func migrateLegacyConfig(root string, options RuntimeValidationOptions, completeSetup bool) (LegacyMigrationResult, error) {
|
||||
plan, err := PlanLegacyMigration(root, options)
|
||||
if err != nil {
|
||||
return LegacyMigrationResult{}, err
|
||||
@@ -168,6 +172,10 @@ func MigrateLegacyConfig(root string, options RuntimeValidationOptions) (LegacyM
|
||||
if err := json.Unmarshal(legacyData, &legacy); err != nil {
|
||||
return LegacyMigrationResult{}, err
|
||||
}
|
||||
if completeSetup {
|
||||
legacy.SetupState = SetupStateReady
|
||||
legacy.IsInit = true
|
||||
}
|
||||
runtime, manualFields, err := legacyRuntimeConfig(root, legacy)
|
||||
if err != nil {
|
||||
return LegacyMigrationResult{}, err
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package config
|
||||
|
||||
// FinalizeSetupConfig 先保存可重试的安装状态,再以分区根文件发布就绪状态。
|
||||
// 只由完成安装的流程调用,不自动迁移已有的运行实例。
|
||||
func FinalizeSetupConfig(cfg *Config) error {
|
||||
legacyConfigMu.Lock()
|
||||
defer legacyConfigMu.Unlock()
|
||||
if cfg == nil {
|
||||
return ErrInvalidRuntimeConfig
|
||||
}
|
||||
|
||||
pending := *cfg
|
||||
pending.SetupState = SetupStateBootstrap
|
||||
pending.IsInit = false
|
||||
if err := writeConfig(&pending); err != nil {
|
||||
return err
|
||||
}
|
||||
if _, err := migrateLegacyConfig(ROOT_PATH, RuntimeValidationOptions{
|
||||
HasSuperAdmin: true,
|
||||
Production: !DevelopmentMode,
|
||||
}, true); err != nil {
|
||||
return err
|
||||
}
|
||||
loaded, err := loadPartitionedCompatibility()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
PublishConfigSnapshot(loaded)
|
||||
return nil
|
||||
}
|
||||
Reference in new issue
Block a user