1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-23 07:19:41 +02:00

feat(dataservices): unify access methods and abstract away redundant code [EE-5628] (#9115)

This commit is contained in:
andres-portainer 2023-06-22 18:28:07 -03:00 committed by GitHub
parent 4c6bbe9a2f
commit 4cc96b4b30
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
171 changed files with 714 additions and 1590 deletions

View file

@ -41,7 +41,7 @@ func (m *Migrator) migrateDBVersionToDB32() error {
func (m *Migrator) updateRegistriesToDB32() error {
log.Info().Msg("updating registries")
registries, err := m.registryService.Registries()
registries, err := m.registryService.ReadAll()
if err != nil {
return err
}
@ -77,7 +77,7 @@ func (m *Migrator) updateRegistriesToDB32() error {
Namespaces: []string{},
}
}
m.registryService.UpdateRegistry(registry.ID, &registry)
m.registryService.Update(registry.ID, &registry)
}
return nil
}
@ -111,7 +111,7 @@ func (m *Migrator) updateDockerhubToDB32() error {
// we only have one migrated registry entry. Duplicates will be removed
// if they exist and which has been happening due to earlier migration bugs
migrated := false
registries, _ := m.registryService.Registries()
registries, _ := m.registryService.ReadAll()
for _, r := range registries {
if r.Type == registry.Type &&
r.Name == registry.Name &&
@ -123,7 +123,7 @@ func (m *Migrator) updateDockerhubToDB32() error {
migrated = true
} else {
// delete subsequent duplicates
m.registryService.DeleteRegistry(portainer.RegistryID(r.ID))
m.registryService.Delete(portainer.RegistryID(r.ID))
}
}
}
@ -180,7 +180,7 @@ func (m *Migrator) updateVolumeResourceControlToDB32() error {
return fmt.Errorf("failed fetching environments: %w", err)
}
resourceControls, err := m.resourceControlService.ResourceControls()
resourceControls, err := m.resourceControlService.ReadAll()
if err != nil {
return fmt.Errorf("failed fetching resource controls: %w", err)
}
@ -228,12 +228,12 @@ func (m *Migrator) updateVolumeResourceControlToDB32() error {
if newResourceID, ok := toUpdate[resourceControl.ID]; ok {
resourceControl.ResourceID = newResourceID
err := m.resourceControlService.UpdateResourceControl(resourceControl.ID, resourceControl)
err := m.resourceControlService.Update(resourceControl.ID, resourceControl)
if err != nil {
return fmt.Errorf("failed updating resource control %d: %w", resourceControl.ID, err)
}
} else {
err := m.resourceControlService.DeleteResourceControl(resourceControl.ID)
err := m.resourceControlService.Delete(resourceControl.ID)
if err != nil {
return fmt.Errorf("failed deleting resource control %d: %w", resourceControl.ID, err)
}