2020-05-25 06:10:02 +00:00
|
|
|
package migrator
|
|
|
|
|
2022-09-16 16:18:44 +00:00
|
|
|
import (
|
|
|
|
portainer "github.com/portainer/portainer/api"
|
|
|
|
|
|
|
|
"github.com/rs/zerolog/log"
|
|
|
|
)
|
2020-08-03 22:18:53 +00:00
|
|
|
|
2020-05-25 06:10:02 +00:00
|
|
|
func (m *Migrator) updateSettingsToDB24() error {
|
2022-09-16 16:18:44 +00:00
|
|
|
log.Info().Msg("updating Settings")
|
2021-11-24 02:58:43 +00:00
|
|
|
|
2020-07-24 23:14:46 +00:00
|
|
|
legacySettings, err := m.settingsService.Settings()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
legacySettings.AllowHostNamespaceForRegularUsers = true
|
2020-07-26 21:31:14 +00:00
|
|
|
legacySettings.AllowDeviceMappingForRegularUsers = true
|
2020-07-27 07:11:32 +00:00
|
|
|
legacySettings.AllowStackManagementForRegularUsers = true
|
2020-07-24 23:14:46 +00:00
|
|
|
|
|
|
|
return m.settingsService.UpdateSettings(legacySettings)
|
2020-05-25 06:10:02 +00:00
|
|
|
}
|
2020-08-03 22:18:53 +00:00
|
|
|
|
|
|
|
func (m *Migrator) updateStacksToDB24() error {
|
2022-09-16 16:18:44 +00:00
|
|
|
log.Info().Msg("updating stacks")
|
|
|
|
|
2023-06-22 21:28:07 +00:00
|
|
|
stacks, err := m.stackService.ReadAll()
|
2020-08-03 22:18:53 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
for idx := range stacks {
|
|
|
|
stack := &stacks[idx]
|
|
|
|
stack.Status = portainer.StackStatusActive
|
2023-06-22 21:28:07 +00:00
|
|
|
err := m.stackService.Update(stack.ID, stack)
|
2020-08-03 22:18:53 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|