From 065fd75337c8b9126c6a47137b3a9ec33b4ded2c 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:21:13 +0100 Subject: [PATCH] :bug: Fix BusinessService CSV import (#766) (#768) 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 540214e2c..2969c985e 100644 --- a/importer/manager.go +++ b/importer/manager.go @@ -166,14 +166,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 @@ -181,7 +181,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 @@ -193,7 +193,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