From d173577f3d4c3a10e1a063d5b4ff8dd8ebe888a3 Mon Sep 17 00:00:00 2001 From: Denis Gukov Date: Sat, 10 Feb 2024 18:23:11 +0500 Subject: [PATCH] feat(backup): add random suffix for resources with the same name --- services/project/backup.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/services/project/backup.go b/services/project/backup.go index 0a56f7dd..b120919e 100644 --- a/services/project/backup.go +++ b/services/project/backup.go @@ -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) {