@@ -407,52 +407,64 @@ func (impl BulkUpdateServiceImpl) BulkUpdateDeploymentTemplate(bulkUpdatePayload
407407 } else {
408408 for _ , chart := range charts {
409409 appDetailsByChart , _ := impl .bulkUpdateRepository .FindAppByChartId (chart .Id )
410- modified , err := impl .ApplyJsonPatch (deploymentTemplatePatch , chart .Values )
410+ modifiedValuesYml , err := impl .ApplyJsonPatch (deploymentTemplatePatch , chart .Values )
411411 if err != nil {
412- impl .logger .Errorw ("error in applying JSON patch" , "err" , err )
412+ impl .logger .Errorw ("error in applying JSON patch to chart.Values " , "err" , err )
413413 bulkUpdateFailedResponse := & DeploymentTemplateBulkUpdateResponseForOneApp {
414414 AppId : appDetailsByChart .Id ,
415415 AppName : appDetailsByChart .AppName ,
416416 Message : fmt .Sprintf ("Error in applying JSON patch : %s" , err .Error ()),
417417 }
418418 deploymentTemplateBulkUpdateResponse .Failure = append (deploymentTemplateBulkUpdateResponse .Failure , bulkUpdateFailedResponse )
419419 } else {
420- err = impl .bulkUpdateRepository . BulkUpdateChartsValuesYamlAndGlobalOverrideById ( chart . Id , modified )
420+ modifiedGlobalOverrideYml , err : = impl .ApplyJsonPatch ( deploymentTemplatePatch , chart . GlobalOverride )
421421 if err != nil {
422- impl .logger .Errorw ("error in bulk updating charts " , "err" , err )
422+ impl .logger .Errorw ("error in applying JSON patch to GlobalOverride " , "err" , err )
423423 bulkUpdateFailedResponse := & DeploymentTemplateBulkUpdateResponseForOneApp {
424424 AppId : appDetailsByChart .Id ,
425425 AppName : appDetailsByChart .AppName ,
426- Message : fmt .Sprintf ("Error in updating in db : %s" , err .Error ()),
426+ Message : fmt .Sprintf ("Error in applying JSON patch : %s" , err .Error ()),
427427 }
428428 deploymentTemplateBulkUpdateResponse .Failure = append (deploymentTemplateBulkUpdateResponse .Failure , bulkUpdateFailedResponse )
429429 } else {
430- bulkUpdateSuccessResponse := & DeploymentTemplateBulkUpdateResponseForOneApp {
431- AppId : appDetailsByChart .Id ,
432- AppName : appDetailsByChart .AppName ,
433- Message : "Updated Successfully" ,
434- }
435- deploymentTemplateBulkUpdateResponse .Successful = append (deploymentTemplateBulkUpdateResponse .Successful , bulkUpdateSuccessResponse )
436-
437- //creating history entry for deployment template
438- appLevelAppMetricsEnabled , err := impl .deployedAppMetricsService .GetMetricsFlagByAppId (chart .AppId )
430+ err = impl .bulkUpdateRepository .BulkUpdateChartsValuesYamlAndGlobalOverrideById (chart .Id , modifiedValuesYml , modifiedGlobalOverrideYml )
439431 if err != nil {
440- impl .logger .Errorw ("error in getting app level metrics app level" , "error" , err , "appId" , chart .AppId )
441- return nil
442- }
443- chart .GlobalOverride = modified
444- chart .Values = modified
445- err = impl .deploymentTemplateHistoryService .CreateDeploymentTemplateHistoryFromGlobalTemplate (chart , nil , appLevelAppMetricsEnabled )
446- if err != nil {
447- impl .logger .Errorw ("error in creating entry for deployment template history" , "err" , err , "chart" , chart )
448- }
449- //VARIABLE_MAPPING_UPDATE
450- //NOTE: this flow is doesn't have the user info, therefore updated by is being set to the last updated by
451- err = impl .scopedVariableManager .ExtractAndMapVariables (chart .GlobalOverride , chart .Id , repository5 .EntityTypeDeploymentTemplateAppLevel , chart .UpdatedBy , nil )
452- if err != nil {
453- return nil
432+ impl .logger .Errorw ("error in bulk updating charts" , "err" , err )
433+ bulkUpdateFailedResponse := & DeploymentTemplateBulkUpdateResponseForOneApp {
434+ AppId : appDetailsByChart .Id ,
435+ AppName : appDetailsByChart .AppName ,
436+ Message : fmt .Sprintf ("Error in updating in db : %s" , err .Error ()),
437+ }
438+ deploymentTemplateBulkUpdateResponse .Failure = append (deploymentTemplateBulkUpdateResponse .Failure , bulkUpdateFailedResponse )
439+ } else {
440+ bulkUpdateSuccessResponse := & DeploymentTemplateBulkUpdateResponseForOneApp {
441+ AppId : appDetailsByChart .Id ,
442+ AppName : appDetailsByChart .AppName ,
443+ Message : "Updated Successfully" ,
444+ }
445+ deploymentTemplateBulkUpdateResponse .Successful = append (deploymentTemplateBulkUpdateResponse .Successful , bulkUpdateSuccessResponse )
446+
447+ //creating history entry for deployment template
448+ appLevelAppMetricsEnabled , err := impl .deployedAppMetricsService .GetMetricsFlagByAppId (chart .AppId )
449+ if err != nil {
450+ impl .logger .Errorw ("error in getting app level metrics app level" , "error" , err , "appId" , chart .AppId )
451+ return nil
452+ }
453+ chart .GlobalOverride = modifiedGlobalOverrideYml
454+ chart .Values = modifiedValuesYml
455+ err = impl .deploymentTemplateHistoryService .CreateDeploymentTemplateHistoryFromGlobalTemplate (chart , nil , appLevelAppMetricsEnabled )
456+ if err != nil {
457+ impl .logger .Errorw ("error in creating entry for deployment template history" , "err" , err , "chart" , chart )
458+ }
459+ //VARIABLE_MAPPING_UPDATE
460+ //NOTE: this flow is doesn't have the user info, therefore updated by is being set to the last updated by
461+ err = impl .scopedVariableManager .ExtractAndMapVariables (chart .GlobalOverride , chart .Id , repository5 .EntityTypeDeploymentTemplateAppLevel , chart .UpdatedBy , nil )
462+ if err != nil {
463+ return nil
464+ }
454465 }
455466 }
467+
456468 }
457469 }
458470 }
0 commit comments