@@ -61,14 +61,15 @@ type AppStoreDeploymentServiceImpl struct {
6161 appStoreDeploymentArgoCdService appStoreDeploymentGitopsTool.AppStoreDeploymentArgoCdService
6262 environmentService cluster.EnvironmentService
6363 clusterService cluster.ClusterService
64+ globalEnvVariables * util2.GlobalEnvVariables
6465}
6566
6667func NewAppStoreDeploymentServiceImpl (logger * zap.SugaredLogger , installedAppRepository appStoreRepository.InstalledAppRepository ,
6768 appStoreApplicationVersionRepository appStoreDiscoverRepository.AppStoreApplicationVersionRepository , environmentRepository clusterRepository.EnvironmentRepository ,
6869 clusterInstalledAppsRepository appStoreRepository.ClusterInstalledAppsRepository , appRepository app.AppRepository ,
6970 appStoreDeploymentHelmService appStoreDeploymentTool.AppStoreDeploymentHelmService ,
7071 appStoreDeploymentArgoCdService appStoreDeploymentGitopsTool.AppStoreDeploymentArgoCdService , environmentService cluster.EnvironmentService ,
71- clusterService cluster.ClusterService ) * AppStoreDeploymentServiceImpl {
72+ clusterService cluster.ClusterService , globalEnvVariables * util2. GlobalEnvVariables ) * AppStoreDeploymentServiceImpl {
7273 return & AppStoreDeploymentServiceImpl {
7374 logger : logger ,
7475 installedAppRepository : installedAppRepository ,
@@ -80,6 +81,7 @@ func NewAppStoreDeploymentServiceImpl(logger *zap.SugaredLogger, installedAppRep
8081 appStoreDeploymentArgoCdService : appStoreDeploymentArgoCdService ,
8182 environmentService : environmentService ,
8283 clusterService : clusterService ,
84+ globalEnvVariables : globalEnvVariables ,
8385 }
8486}
8587
@@ -130,6 +132,9 @@ func (impl AppStoreDeploymentServiceImpl) AppStoreDeployOperationDB(installAppVe
130132 installedAppModel .CreatedOn = time .Now ()
131133 installedAppModel .UpdatedOn = time .Now ()
132134 installedAppModel .Active = true
135+ if util2 .GetDevtronVersion ().ServerMode == util2 .SERVER_MODE_FULL {
136+ installedAppModel .GitOpsRepoName = impl .GetGitOpsRepoName (appStoreAppVersion .AppStore .Name )
137+ }
133138 installedApp , err := impl .installedAppRepository .CreateInstalledApp (installedAppModel , tx )
134139 if err != nil {
135140 impl .logger .Errorw ("error while creating install app" , "error" , err )
@@ -175,6 +180,17 @@ func (impl AppStoreDeploymentServiceImpl) AppStoreDeployOperationDB(installAppVe
175180 return installAppVersionRequest , nil
176181}
177182
183+ //TODO - dedupe, move it to one location
184+ func (impl AppStoreDeploymentServiceImpl ) GetGitOpsRepoName (appName string ) string {
185+ var repoName string
186+ if len (impl .globalEnvVariables .GitOpsRepoPrefix ) == 0 {
187+ repoName = appName
188+ } else {
189+ repoName = fmt .Sprintf ("%s-%s" , impl .globalEnvVariables .GitOpsRepoPrefix , appName )
190+ }
191+ return repoName
192+ }
193+
178194func (impl AppStoreDeploymentServiceImpl ) AppStoreDeployOperationStatusUpdate (installAppId int , status appStoreBean.AppstoreDeploymentStatus ) (bool , error ) {
179195 dbConnection := impl .installedAppRepository .GetConnection ()
180196 tx , err := dbConnection .Begin ()
@@ -344,9 +360,9 @@ func (impl AppStoreDeploymentServiceImpl) GetAllInstalledAppsByAppStoreId(w http
344360 var installedAppsEnvResponse []appStoreBean.InstalledAppsResponse
345361 for _ , a := range installedApps {
346362 var status string
347- if util2 .GetDevtronVersion ().ServerMode == util2 .SERVER_MODE_HYPERION || a .AppOfferingMode == util2 .SERVER_MODE_HYPERION {
363+ if util2 .GetDevtronVersion ().ServerMode == util2 .SERVER_MODE_HYPERION || a .AppOfferingMode == util2 .SERVER_MODE_HYPERION {
348364 status , err = impl .appStoreDeploymentHelmService .GetAppStatus (a , w , r , token )
349- }else {
365+ } else {
350366 status , err = impl .appStoreDeploymentArgoCdService .GetAppStatus (a , w , r , token )
351367 }
352368 if apiErr , ok := err .(* util.ApiError ); ok {
@@ -444,9 +460,9 @@ func (impl AppStoreDeploymentServiceImpl) DeleteInstalledApp(ctx context.Context
444460 }
445461 }
446462
447- if util2 .GetDevtronVersion ().ServerMode == util2 .SERVER_MODE_HYPERION || app .AppOfferingMode == util2 .SERVER_MODE_HYPERION {
463+ if util2 .GetDevtronVersion ().ServerMode == util2 .SERVER_MODE_HYPERION || app .AppOfferingMode == util2 .SERVER_MODE_HYPERION {
448464 err = impl .appStoreDeploymentHelmService .DeleteInstalledApp (ctx , app .AppName , environment .Name , installAppVersionRequest , model , tx )
449- }else {
465+ } else {
450466 err = impl .appStoreDeploymentArgoCdService .DeleteInstalledApp (ctx , app .AppName , environment .Name , installAppVersionRequest , model , tx )
451467 }
452468
0 commit comments