From ca7ce6e0e1fd7e0e27cc51227c4b8a61dfb9464f Mon Sep 17 00:00:00 2001 From: "konveyor-ci-bot[bot]" <159171263+konveyor-ci-bot[bot]@users.noreply.github.com> Date: Tue, 26 Nov 2024 08:20:49 +0100 Subject: [PATCH] :bug: Fix BusinessService CSV import (#766) (#767) CSV importer code used to set the last existing BussinessService to an Application, updating businessService variable from Ref to Value to keep the found BusinessService until it is saved in Application. Fixes: https://issues.redhat.com/browse/MTA-4257 Signed-off-by: Marek Aufart Signed-off-by: Cherry Picker Signed-off-by: Marek Aufart Signed-off-by: Cherry Picker Co-authored-by: Marek Aufart --- importer/manager.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/importer/manager.go b/importer/manager.go index b11f45e4b..275db132b 100644 --- a/importer/manager.go +++ b/importer/manager.go @@ -168,14 +168,14 @@ func (m *Manager) createApplication(imp *model.Import) (ok bool) { } // Assign Business Service - businessService := &model.BusinessService{} + businessService := model.BusinessService{} businessServices := []model.BusinessService{} m.DB.Find(&businessServices) normBusinessServiceName := normalizedName(imp.BusinessService) // Find existing BusinessService for _, bs := range businessServices { if normalizedName(bs.Name) == normBusinessServiceName { - businessService = &bs + businessService = bs } } // If not found business service in database and import specifies some non-empty business service, proceeed with create it @@ -183,7 +183,7 @@ func (m *Manager) createApplication(imp *model.Import) (ok bool) { if imp.ImportSummary.CreateEntities { // Create a new BusinessService if not existed businessService.Name = imp.BusinessService - result := m.DB.Create(businessService) + result := m.DB.Create(&businessService) if result.Error != nil { imp.ErrorMessage = fmt.Sprintf("BusinessService '%s' cannot be created.", imp.BusinessService) return @@ -195,7 +195,7 @@ func (m *Manager) createApplication(imp *model.Import) (ok bool) { } // Assign business service to the application if was specified if businessService.ID != 0 { - app.BusinessService = businessService + app.BusinessService = &businessService } // Process import Tags & TagCategories