@@ -30,7 +30,7 @@ type DeploymentConfigReadService interface {
3030
3131	GetDeploymentConfigForApp (tx  * pg.Tx , appId  int ) (* bean.DeploymentConfig , bool , error )
3232	GetDeploymentConfigForAppAndEnv (tx  * pg.Tx , appLevelConfig  * bean.DeploymentConfig , appId , envId  int ) (* bean.DeploymentConfig , bool , error )
33- 	ParseEnvLevelReleaseConfigForDevtronApp (config  * bean.DeploymentConfig , appId  int , envId  int ) (* bean.ReleaseConfiguration , error )
33+ 	ParseEnvLevelReleaseConfigForDevtronApp (tx   * pg. Tx ,  config  * bean.DeploymentConfig , appId  int , envId  int ) (* bean.ReleaseConfiguration , error )
3434}
3535
3636type  DeploymentConfigReadServiceImpl  struct  {
@@ -130,7 +130,7 @@ func (impl *DeploymentConfigReadServiceImpl) GetDeploymentConfigForApp(tx *pg.Tx
130130		return  appLevelConfig , isMigrationNeeded , err 
131131	} else  if  interalUtil .IsErrNoRows (err ) {
132132		isMigrationNeeded  =  true 
133- 		appLevelConfig , err  =  impl .parseAppLevelMigrationDataForDevtronApps (appId )
133+ 		appLevelConfig , err  =  impl .parseAppLevelMigrationDataForDevtronApps (tx ,  appId )
134134		if  err  !=  nil  {
135135			impl .logger .Errorw ("error in migrating app level config to deployment config" , "appId" , appId , "err" , err )
136136			return  appLevelConfig , isMigrationNeeded , err 
@@ -143,7 +143,7 @@ func (impl *DeploymentConfigReadServiceImpl) GetDeploymentConfigForApp(tx *pg.Tx
143143		}
144144		if  appLevelConfig .ReleaseConfiguration  ==  nil  ||  len (appLevelConfig .ReleaseConfiguration .Version ) ==  0  {
145145			isMigrationNeeded  =  true 
146- 			releaseConfig , err  :=  impl .parseAppLevelReleaseConfigForDevtronApp (appId , appLevelConfig )
146+ 			releaseConfig , err  :=  impl .parseAppLevelReleaseConfigForDevtronApp (tx ,  appId , appLevelConfig )
147147			if  err  !=  nil  {
148148				impl .logger .Errorw ("error in parsing release configuration for app" , "appId" , appId , "err" , err )
149149				return  appLevelConfig , isMigrationNeeded , err 
@@ -165,7 +165,7 @@ func (impl *DeploymentConfigReadServiceImpl) GetDeploymentConfigForAppAndEnv(tx
165165		return  envLevelConfig , isMigrationNeeded , err 
166166	} else  if  interalUtil .IsErrNoRows (err ) {
167167		// case: deployment config data is not yet migrated 
168- 		envLevelConfig , err  =  impl .parseEnvLevelMigrationDataForDevtronApps (appLevelConfig , appId , envId )
168+ 		envLevelConfig , err  =  impl .parseEnvLevelMigrationDataForDevtronApps (tx ,  appLevelConfig , appId , envId )
169169		if  err  !=  nil  {
170170			impl .logger .Errorw ("error in parsing env level config to deployment config" , "appId" , appId , "envId" , envId , "err" , err )
171171			return  envLevelConfig , isMigrationNeeded , err 
@@ -180,7 +180,7 @@ func (impl *DeploymentConfigReadServiceImpl) GetDeploymentConfigForAppAndEnv(tx
180180		// case: deployment config is migrated; but release config is absent. 
181181		if  envLevelConfig .ReleaseConfiguration  ==  nil  ||  len (envLevelConfig .ReleaseConfiguration .Version ) ==  0  {
182182			isMigrationNeeded  =  true 
183- 			releaseConfig , err  :=  impl .ParseEnvLevelReleaseConfigForDevtronApp (envLevelConfig , appId , envId )
183+ 			releaseConfig , err  :=  impl .ParseEnvLevelReleaseConfigForDevtronApp (tx ,  envLevelConfig , appId , envId )
184184			if  err  !=  nil  {
185185				impl .logger .Errorw ("error in parsing env level release config" , "appId" , appId , "envId" , envId , "err" , err )
186186				return  envLevelConfig , isMigrationNeeded , err 
@@ -257,7 +257,7 @@ func (impl *DeploymentConfigReadServiceImpl) configureEnvURLByAppURLIfNotConfigu
257257	return  appAndEnvLevelConfig , isRepoUrlUpdated , nil 
258258}
259259
260- func  (impl  * DeploymentConfigReadServiceImpl ) parseEnvLevelMigrationDataForDevtronApps (appLevelConfig  * bean.DeploymentConfig , appId , envId  int ) (* bean.DeploymentConfig , error ) {
260+ func  (impl  * DeploymentConfigReadServiceImpl ) parseEnvLevelMigrationDataForDevtronApps (tx   * pg. Tx ,  appLevelConfig  * bean.DeploymentConfig , appId , envId  int ) (* bean.DeploymentConfig , error ) {
261261	/* 
262262		We can safely assume that no link argoCD pipeline is created if migration is happening 
263263		migration case, default values for below fields will be => 
@@ -284,7 +284,7 @@ func (impl *DeploymentConfigReadServiceImpl) parseEnvLevelMigrationDataForDevtro
284284	}
285285	config .DeploymentAppType  =  deploymentAppType 
286286
287- 	releaseConfig , err  :=  impl .ParseEnvLevelReleaseConfigForDevtronApp (config , appId , envId )
287+ 	releaseConfig , err  :=  impl .ParseEnvLevelReleaseConfigForDevtronApp (tx ,  config , appId , envId )
288288	if  err  !=  nil  {
289289		impl .logger .Errorw ("error in parsing env level release config" , "appId" , appId , "envId" , envId , "err" , err )
290290		return  nil , err 
@@ -327,18 +327,18 @@ func (impl *DeploymentConfigReadServiceImpl) getConfigMetaDataForAppAndEnv(appId
327327	return  environmentId , deploymentAppName , namespace , nil 
328328}
329329
330- func  (impl  * DeploymentConfigReadServiceImpl ) ParseEnvLevelReleaseConfigForDevtronApp (config  * bean.DeploymentConfig , appId  int , envId  int ) (* bean.ReleaseConfiguration , error ) {
330+ func  (impl  * DeploymentConfigReadServiceImpl ) ParseEnvLevelReleaseConfigForDevtronApp (tx   * pg. Tx ,  config  * bean.DeploymentConfig , appId  int , envId  int ) (* bean.ReleaseConfiguration , error ) {
331331	releaseConfig  :=  & bean.ReleaseConfiguration {}
332332	if  config .DeploymentAppType  ==  interalUtil .PIPELINE_DEPLOYMENT_TYPE_ACD  {
333333		releaseConfig .Version  =  bean .Version 
334- 		envOverride , err  :=  impl .envConfigOverrideService .FindLatestChartForAppByAppIdAndEnvId (appId , envId )
334+ 		envOverride , err  :=  impl .envConfigOverrideService .FindLatestChartForAppByAppIdAndEnvId (tx ,  appId , envId )
335335		if  err  !=  nil  &&  ! errors .IsNotFound (err ) {
336336			impl .logger .Errorw ("error in fetch" )
337337			return  nil , err 
338338		}
339339		var  latestChart  * chartRepoRepository.Chart 
340340		if  ! envOverride .IsOverridden () {
341- 			latestChart , err  =  impl .chartRepository .FindLatestChartForAppByAppId (appId )
341+ 			latestChart , err  =  impl .chartRepository .FindLatestChartForAppByAppId (tx ,  appId )
342342			if  err  !=  nil  {
343343				return  nil , err 
344344			}
@@ -380,8 +380,8 @@ func (impl *DeploymentConfigReadServiceImpl) ParseEnvLevelReleaseConfigForDevtro
380380	return  releaseConfig , nil 
381381}
382382
383- func  (impl  * DeploymentConfigReadServiceImpl ) parseAppLevelMigrationDataForDevtronApps (appId  int ) (* bean.DeploymentConfig , error ) {
384- 	chart , err  :=  impl .chartRepository .FindLatestChartForAppByAppId (appId )
383+ func  (impl  * DeploymentConfigReadServiceImpl ) parseAppLevelMigrationDataForDevtronApps (tx   * pg. Tx ,  appId  int ) (* bean.DeploymentConfig , error ) {
384+ 	chart , err  :=  impl .chartRepository .FindLatestChartForAppByAppId (tx ,  appId )
385385	if  err  !=  nil  {
386386		return  nil , err 
387387	}
@@ -398,8 +398,8 @@ func (impl *DeploymentConfigReadServiceImpl) parseAppLevelMigrationDataForDevtro
398398	return  config , nil 
399399}
400400
401- func  (impl  * DeploymentConfigReadServiceImpl ) parseAppLevelReleaseConfigForDevtronApp (appId  int , appLevelConfig  * bean.DeploymentConfig ) (* bean.ReleaseConfiguration , error ) {
402- 	chart , err  :=  impl .chartRepository .FindLatestChartForAppByAppId (appId )
401+ func  (impl  * DeploymentConfigReadServiceImpl ) parseAppLevelReleaseConfigForDevtronApp (tx   * pg. Tx ,  appId  int , appLevelConfig  * bean.DeploymentConfig ) (* bean.ReleaseConfiguration , error ) {
402+ 	chart , err  :=  impl .chartRepository .FindLatestChartForAppByAppId (tx ,  appId )
403403	if  err  !=  nil  {
404404		return  nil , err 
405405	}
@@ -408,6 +408,7 @@ func (impl *DeploymentConfigReadServiceImpl) parseAppLevelReleaseConfigForDevtro
408408	if  len (appLevelConfig .RepoURL ) >  0  {
409409		repoURL  =  appLevelConfig .RepoURL 
410410	}
411+ 
411412	chartLocation  :=  filepath .Join (chart .ReferenceTemplate , chart .ChartVersion )
412413	releaseConfig  :=  adapter .NewAppLevelReleaseConfigFromChart (repoURL , chartLocation )
413414	return  releaseConfig , nil 
0 commit comments