@@ -30,7 +30,7 @@ type DeploymentConfigReadService interface {
30
30
31
31
GetDeploymentConfigForApp (tx * pg.Tx , appId int ) (* bean.DeploymentConfig , bool , error )
32
32
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 )
34
34
}
35
35
36
36
type DeploymentConfigReadServiceImpl struct {
@@ -130,7 +130,7 @@ func (impl *DeploymentConfigReadServiceImpl) GetDeploymentConfigForApp(tx *pg.Tx
130
130
return appLevelConfig , isMigrationNeeded , err
131
131
} else if interalUtil .IsErrNoRows (err ) {
132
132
isMigrationNeeded = true
133
- appLevelConfig , err = impl .parseAppLevelMigrationDataForDevtronApps (appId )
133
+ appLevelConfig , err = impl .parseAppLevelMigrationDataForDevtronApps (tx , appId )
134
134
if err != nil {
135
135
impl .logger .Errorw ("error in migrating app level config to deployment config" , "appId" , appId , "err" , err )
136
136
return appLevelConfig , isMigrationNeeded , err
@@ -143,7 +143,7 @@ func (impl *DeploymentConfigReadServiceImpl) GetDeploymentConfigForApp(tx *pg.Tx
143
143
}
144
144
if appLevelConfig .ReleaseConfiguration == nil || len (appLevelConfig .ReleaseConfiguration .Version ) == 0 {
145
145
isMigrationNeeded = true
146
- releaseConfig , err := impl .parseAppLevelReleaseConfigForDevtronApp (appId , appLevelConfig )
146
+ releaseConfig , err := impl .parseAppLevelReleaseConfigForDevtronApp (tx , appId , appLevelConfig )
147
147
if err != nil {
148
148
impl .logger .Errorw ("error in parsing release configuration for app" , "appId" , appId , "err" , err )
149
149
return appLevelConfig , isMigrationNeeded , err
@@ -165,7 +165,7 @@ func (impl *DeploymentConfigReadServiceImpl) GetDeploymentConfigForAppAndEnv(tx
165
165
return envLevelConfig , isMigrationNeeded , err
166
166
} else if interalUtil .IsErrNoRows (err ) {
167
167
// 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 )
169
169
if err != nil {
170
170
impl .logger .Errorw ("error in parsing env level config to deployment config" , "appId" , appId , "envId" , envId , "err" , err )
171
171
return envLevelConfig , isMigrationNeeded , err
@@ -180,7 +180,7 @@ func (impl *DeploymentConfigReadServiceImpl) GetDeploymentConfigForAppAndEnv(tx
180
180
// case: deployment config is migrated; but release config is absent.
181
181
if envLevelConfig .ReleaseConfiguration == nil || len (envLevelConfig .ReleaseConfiguration .Version ) == 0 {
182
182
isMigrationNeeded = true
183
- releaseConfig , err := impl .ParseEnvLevelReleaseConfigForDevtronApp (envLevelConfig , appId , envId )
183
+ releaseConfig , err := impl .ParseEnvLevelReleaseConfigForDevtronApp (tx , envLevelConfig , appId , envId )
184
184
if err != nil {
185
185
impl .logger .Errorw ("error in parsing env level release config" , "appId" , appId , "envId" , envId , "err" , err )
186
186
return envLevelConfig , isMigrationNeeded , err
@@ -257,7 +257,7 @@ func (impl *DeploymentConfigReadServiceImpl) configureEnvURLByAppURLIfNotConfigu
257
257
return appAndEnvLevelConfig , isRepoUrlUpdated , nil
258
258
}
259
259
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 ) {
261
261
/*
262
262
We can safely assume that no link argoCD pipeline is created if migration is happening
263
263
migration case, default values for below fields will be =>
@@ -284,7 +284,7 @@ func (impl *DeploymentConfigReadServiceImpl) parseEnvLevelMigrationDataForDevtro
284
284
}
285
285
config .DeploymentAppType = deploymentAppType
286
286
287
- releaseConfig , err := impl .ParseEnvLevelReleaseConfigForDevtronApp (config , appId , envId )
287
+ releaseConfig , err := impl .ParseEnvLevelReleaseConfigForDevtronApp (tx , config , appId , envId )
288
288
if err != nil {
289
289
impl .logger .Errorw ("error in parsing env level release config" , "appId" , appId , "envId" , envId , "err" , err )
290
290
return nil , err
@@ -327,18 +327,18 @@ func (impl *DeploymentConfigReadServiceImpl) getConfigMetaDataForAppAndEnv(appId
327
327
return environmentId , deploymentAppName , namespace , nil
328
328
}
329
329
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 ) {
331
331
releaseConfig := & bean.ReleaseConfiguration {}
332
332
if config .DeploymentAppType == interalUtil .PIPELINE_DEPLOYMENT_TYPE_ACD {
333
333
releaseConfig .Version = bean .Version
334
- envOverride , err := impl .envConfigOverrideService .FindLatestChartForAppByAppIdAndEnvId (appId , envId )
334
+ envOverride , err := impl .envConfigOverrideService .FindLatestChartForAppByAppIdAndEnvId (tx , appId , envId )
335
335
if err != nil && ! errors .IsNotFound (err ) {
336
336
impl .logger .Errorw ("error in fetch" )
337
337
return nil , err
338
338
}
339
339
var latestChart * chartRepoRepository.Chart
340
340
if ! envOverride .IsOverridden () {
341
- latestChart , err = impl .chartRepository .FindLatestChartForAppByAppId (appId )
341
+ latestChart , err = impl .chartRepository .FindLatestChartForAppByAppId (tx , appId )
342
342
if err != nil {
343
343
return nil , err
344
344
}
@@ -380,8 +380,8 @@ func (impl *DeploymentConfigReadServiceImpl) ParseEnvLevelReleaseConfigForDevtro
380
380
return releaseConfig , nil
381
381
}
382
382
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 )
385
385
if err != nil {
386
386
return nil , err
387
387
}
@@ -398,8 +398,8 @@ func (impl *DeploymentConfigReadServiceImpl) parseAppLevelMigrationDataForDevtro
398
398
return config , nil
399
399
}
400
400
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 )
403
403
if err != nil {
404
404
return nil , err
405
405
}
@@ -408,6 +408,7 @@ func (impl *DeploymentConfigReadServiceImpl) parseAppLevelReleaseConfigForDevtro
408
408
if len (appLevelConfig .RepoURL ) > 0 {
409
409
repoURL = appLevelConfig .RepoURL
410
410
}
411
+
411
412
chartLocation := filepath .Join (chart .ReferenceTemplate , chart .ChartVersion )
412
413
releaseConfig := adapter .NewAppLevelReleaseConfigFromChart (repoURL , chartLocation )
413
414
return releaseConfig , nil
0 commit comments