mirror of
https://github.com/portainer/portainer.git
synced 2025-07-24 07:49:41 +02:00
feat(version): migrate version to semver [EE-3756] (#7693)
redisigned version bucket and migration code
This commit is contained in:
parent
4cfa584c7c
commit
583346321e
27 changed files with 747 additions and 509 deletions
|
@ -5,6 +5,7 @@ import (
|
|||
|
||||
portainer "github.com/portainer/portainer/api"
|
||||
"github.com/portainer/portainer/api/database"
|
||||
"github.com/portainer/portainer/api/database/models"
|
||||
"github.com/portainer/portainer/api/filesystem"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
|
@ -21,7 +22,9 @@ func MustNewTestStore(t *testing.T, init, secure bool) (bool, *Store, func()) {
|
|||
newStore, store, teardown, err := NewTestStore(t, init, secure)
|
||||
if err != nil {
|
||||
if !errors.Is(err, errTempDir) {
|
||||
teardown()
|
||||
if teardown != nil {
|
||||
teardown()
|
||||
}
|
||||
}
|
||||
|
||||
log.Fatal().Err(err).Msg("")
|
||||
|
@ -33,6 +36,7 @@ func MustNewTestStore(t *testing.T, init, secure bool) (bool, *Store, func()) {
|
|||
func NewTestStore(t *testing.T, init, secure bool) (bool, *Store, func(), error) {
|
||||
// Creates unique temp directory in a concurrency friendly manner.
|
||||
storePath := t.TempDir()
|
||||
|
||||
fileService, err := filesystem.NewService(storePath, "")
|
||||
if err != nil {
|
||||
return false, nil, nil, err
|
||||
|
@ -54,8 +58,6 @@ func NewTestStore(t *testing.T, init, secure bool) (bool, *Store, func(), error)
|
|||
return newStore, nil, nil, err
|
||||
}
|
||||
|
||||
log.Debug().Msg("opened")
|
||||
|
||||
if init {
|
||||
err = store.Init()
|
||||
if err != nil {
|
||||
|
@ -63,11 +65,13 @@ func NewTestStore(t *testing.T, init, secure bool) (bool, *Store, func(), error)
|
|||
}
|
||||
}
|
||||
|
||||
log.Debug().Msg("initialised")
|
||||
|
||||
if newStore {
|
||||
// from MigrateData
|
||||
store.VersionService.StoreDBVersion(portainer.DBVersion)
|
||||
v := models.Version{
|
||||
SchemaVersion: portainer.APIVersion,
|
||||
Edition: int(portainer.PortainerCE),
|
||||
}
|
||||
err = store.VersionService.UpdateVersion(&v)
|
||||
if err != nil {
|
||||
return newStore, nil, nil, err
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue