fix(api): set a default value for potentially empty snapshot interval (#2543)

pull/2550/head^2 1.20.0
Anthony Lapenna 2018-12-12 21:16:44 +13:00 committed by GitHub
parent 6648c0bbe7
commit 6b05a35881
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 1 deletions

View File

@ -0,0 +1,14 @@
package migrator
func (m *Migrator) updateSettingsToDBVersion16() error {
legacySettings, err := m.settingsService.Settings()
if err != nil {
return err
}
if legacySettings.SnapshotInterval == "" {
legacySettings.SnapshotInterval = "5m"
}
return m.settingsService.UpdateSettings(legacySettings)
}

View File

@ -203,5 +203,12 @@ func (m *Migrator) Migrate() error {
}
}
if m.currentDBVersion < 16 {
err := m.updateSettingsToDBVersion16()
if err != nil {
return err
}
}
return m.versionService.StoreDBVersion(portainer.DBVersion)
}

View File

@ -780,7 +780,7 @@ const (
// APIVersion is the version number of the Portainer API
APIVersion = "1.20.0"
// DBVersion is the version number of the Portainer database
DBVersion = 15
DBVersion = 16
// AssetsServerURL represents the URL of the Portainer asset server
AssetsServerURL = "https://portainer-io-assets.sfo2.digitaloceanspaces.com"
// MessageOfTheDayURL represents the URL where Portainer MOTD message can be retrieved