@@ -463,22 +463,22 @@ func convertUrlToHttpsIfSshType(url string) string {
463463}
464464
465465// getAppAndProjectForAppIdentifier, returns app db model for an app unique identifier or from display_name if both exists else it throws pg.ErrNoRows 
466- func  (impl  AppCrudOperationServiceImpl ) getAppAndProjectForAppIdentifier (appIdentifier  * helmBean.AppIdentifier ) (* appRepository.App , error ) {
466+ func  (impl  AppCrudOperationServiceImpl ) getAppAndProjectForAppIdentifier (appIdentifier  * helmBean.AppIdentifier ) (* appRepository.App , bool ,  error ) {
467467	app  :=  & appRepository.App {}
468468	var  err  error 
469469	appNameUniqueIdentifier  :=  appIdentifier .GetUniqueAppNameIdentifier ()
470470	app , err  =  impl .appRepository .FindAppAndProjectByAppName (appNameUniqueIdentifier )
471471	if  err  !=  nil  &&  err  !=  pg .ErrNoRows  &&  err  !=  pg .ErrMultiRows  {
472472		impl .logger .Errorw ("error in fetching app meta data by unique app identifier" , "appNameUniqueIdentifier" , appNameUniqueIdentifier , "err" , err )
473- 		return  app , err 
473+ 		return  app , false ,  err 
474474	}
475475	if  err  ==  pg .ErrMultiRows  {
476476		validApp , err  :=  impl .dbMigration .FixMultipleAppsForInstalledApp (appNameUniqueIdentifier )
477477		if  err  !=  nil  {
478478			impl .logger .Errorw ("error in fixing multiple installed app entries" , "appName" , appNameUniqueIdentifier , "err" , err )
479- 			return  app , err 
479+ 			return  app , false ,  err 
480480		}
481- 		return  validApp , err 
481+ 		return  validApp , false ,  err 
482482	}
483483	if  util .IsErrNoRows (err ) {
484484		//find app by display name if not found by unique identifier 
@@ -487,16 +487,28 @@ func (impl AppCrudOperationServiceImpl) getAppAndProjectForAppIdentifier(appIden
487487			validApp , err  :=  impl .dbMigration .FixMultipleAppsForInstalledApp (appNameUniqueIdentifier )
488488			if  err  !=  nil  {
489489				impl .logger .Errorw ("error in fixing multiple installed app entries" , "appName" , appNameUniqueIdentifier , "err" , err )
490- 				return  app , err 
490+ 				return  app , false ,  err 
491491			}
492- 			return  validApp , err 
492+ 			return  validApp , false ,  err 
493493		}
494494		if  err  !=  nil  {
495495			impl .logger .Errorw ("error in fetching app meta data by display name" , "displayName" , appIdentifier .ReleaseName , "err" , err )
496- 			return  app , err 
496+ 			return  app , false , err 
497+ 		}
498+ 		// there can be a case when an app whose installed_app is deployed via argocd and same appName is also deployed externally 
499+ 		// via helm then we need to check if app model found is not deployed by argocd. 
500+ 		isManagedByArgocd , err  :=  impl .installedAppDbService .IsChartStoreAppManagedByArgoCd (app .Id )
501+ 		if  err  !=  nil  {
502+ 			impl .logger .Errorw ("error in checking if installed app linked to this app is managed via argocd or not " , "appId" , app .Id , "err" , err )
503+ 			return  app , false , err 
504+ 		}
505+ 		if  isManagedByArgocd  {
506+ 			// if this helm app is managed by argocd then we don't want to process this req. any further. 
507+ 			return  app , true , nil 
497508		}
498509	}
499- 	return  app , nil 
510+ 
511+ 	return  app , false , nil 
500512}
501513
502514// updateAppNameToUniqueAppIdentifierInApp, migrates values of app_name col. in app table to unique identifier and also updates display_name with releaseName 
@@ -540,18 +552,25 @@ func (impl AppCrudOperationServiceImpl) GetHelmAppMetaInfo(appId string) (*bean.
540552	app  :=  & appRepository.App {}
541553	var  err  error 
542554	var  displayName  string 
555+ 	var  isManagedByArgocd  bool 
543556	impl .logger .Info ("request payload, appId" , appId )
544557	if  len (appIdSplitted ) >  1  {
545558		appIdDecoded , err  :=  client .DecodeExternalAppAppId (appId )
546559		if  err  !=  nil  {
547560			impl .logger .Errorw ("error in decoding app id for external app" , "appId" , appId , "err" , err )
548561			return  nil , err 
549562		}
550- 		app , err  =  impl .getAppAndProjectForAppIdentifier (appIdDecoded )
563+ 		app , isManagedByArgocd ,  err  =  impl .getAppAndProjectForAppIdentifier (appIdDecoded )
551564		if  err  !=  nil  &&  ! util .IsErrNoRows (err ) {
552565			impl .logger .Errorw ("GetHelmAppMetaInfo, error in getAppAndProjectForAppIdentifier for external apps" , "appIdentifier" , appIdDecoded , "err" , err )
553566			return  nil , err 
554567		}
568+ 		if  isManagedByArgocd  {
569+ 			info  :=  & bean.AppMetaInfoDto {
570+ 				AppName : appIdDecoded .ReleaseName ,
571+ 			}
572+ 			return  info , nil 
573+ 		}
555574		// if app.DisplayName is empty then that app_name is not yet migrated to app name unique identifier 
556575		if  app .Id  >  0  &&  len (app .DisplayName ) ==  0  {
557576			appNameUniqueIdentifier  :=  appIdDecoded .GetUniqueAppNameIdentifier ()
0 commit comments