feat(backup): add random suffix for resources with the same name

This commit is contained in:
Denis Gukov 2024-02-10 18:23:11 +05:00
parent 813358b266
commit d173577f3d

View File

@ -88,11 +88,29 @@ func (b *BackupDB) makeUniqueNames() {
item.Name = name
})
makeUniqueNames(b.inventories, func(item *db.Inventory) string {
return item.Name
}, func(item *db.Inventory, name string) {
item.Name = name
})
makeUniqueNames(b.environments, func(item *db.Environment) string {
return item.Name
}, func(item *db.Environment, name string) {
item.Name = name
})
makeUniqueNames(b.keys, func(item *db.AccessKey) string {
return item.Name
}, func(item *db.AccessKey, name string) {
item.Name = name
})
makeUniqueNames(b.views, func(item *db.View) string {
return item.Title
}, func(item *db.View, name string) {
item.Title = name
})
}
func (b *BackupDB) new(projectID int, store db.Store) (*BackupDB, error) {