Skip to content

Commit be944f5

Browse files
authored
updated audit info for cd pipeline delete req (#3404) (#220)
1 parent f4b37f4 commit be944f5

File tree

5 files changed

+11
-10
lines changed

5 files changed

+11
-10
lines changed

api/router/pubsub/ApplicationStatusHandler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ func (impl *ApplicationStatusHandlerImpl) updateArgoAppDeleteStatus(app *v1alpha
240240
}
241241
} else {
242242
// devtron app
243-
err = impl.pipelineBuilder.DeleteCdPipeline(&pipeline, context.Background(), true, false, 0)
243+
err = impl.pipelineBuilder.DeleteCdPipeline(&pipeline, context.Background(), true, false, 1)
244244
if err != nil {
245245
impl.logger.Errorw("error in deleting cd pipeline", "err", err)
246246
return err

internal/sql/repository/pipelineConfig/PipelineRepository.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ type PipelineRepository interface {
9595
Save(pipeline []*Pipeline, tx *pg.Tx) error
9696
Update(pipeline *Pipeline, tx *pg.Tx) error
9797
FindActiveByAppId(appId int) (pipelines []*Pipeline, err error)
98-
Delete(id int, tx *pg.Tx) error
98+
Delete(id int, userId int32, tx *pg.Tx) error
9999
FindByName(pipelineName string) (pipeline *Pipeline, err error)
100100
PipelineExists(pipelineName string) (bool, error)
101101
FindById(id int) (pipeline *Pipeline, err error)
@@ -277,9 +277,10 @@ func (impl PipelineRepositoryImpl) FindActiveByAppIdAndEnvironmentIdV2() (pipeli
277277
return pipelines, err
278278
}
279279

280-
func (impl PipelineRepositoryImpl) Delete(id int, tx *pg.Tx) error {
280+
func (impl PipelineRepositoryImpl) Delete(id int, userId int32, tx *pg.Tx) error {
281281
pipeline := &Pipeline{}
282-
r, err := tx.Model(pipeline).Set("deleted =?", true).Set("deployment_app_created =?", false).Where("id =?", id).Update()
282+
r, err := tx.Model(pipeline).Set("deleted =?", true).Set("deployment_app_created =?", false).
283+
Set("updated_on = ?", time.Now()).Set("updated_by = ?", userId).Where("id =?", id).Update()
283284
impl.logger.Debugw("update result", "r-affected", r.RowsAffected(), "r-return", r.RowsReturned(), "model", r.Model())
284285
return err
285286
}

internal/sql/repository/pipelineConfig/mocks/PipelineRepository.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/pipeline/CiCdPipelineOrchestrator.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ type CiCdPipelineOrchestrator interface {
6767
CreateCDPipelines(pipelineRequest *bean.CDPipelineConfigObject, appId int, userId int32, tx *pg.Tx, appName string) (pipelineId int, err error)
6868
UpdateCDPipeline(pipelineRequest *bean.CDPipelineConfigObject, userId int32, tx *pg.Tx) (err error)
6969
DeleteCiPipeline(pipeline *pipelineConfig.CiPipeline, request *bean.CiPatchRequest, tx *pg.Tx) error
70-
DeleteCdPipeline(pipelineId int, tx *pg.Tx) error
70+
DeleteCdPipeline(pipelineId int, userId int32, tx *pg.Tx) error
7171
PatchMaterialValue(createRequest *bean.CiPipeline, userId int32, oldPipeline *pipelineConfig.CiPipeline) (*bean.CiPipeline, error)
7272
PipelineExists(name string) (bool, error)
7373
GetCdPipelinesForApp(appId int) (cdPipelines *bean.CdPipelines, err error)
@@ -1311,8 +1311,8 @@ func (impl CiCdPipelineOrchestratorImpl) UpdateCDPipeline(pipelineRequest *bean.
13111311
return err
13121312
}
13131313

1314-
func (impl CiCdPipelineOrchestratorImpl) DeleteCdPipeline(pipelineId int, tx *pg.Tx) error {
1315-
return impl.pipelineRepository.Delete(pipelineId, tx)
1314+
func (impl CiCdPipelineOrchestratorImpl) DeleteCdPipeline(pipelineId int, userId int32, tx *pg.Tx) error {
1315+
return impl.pipelineRepository.Delete(pipelineId, userId, tx)
13161316
}
13171317

13181318
func (impl CiCdPipelineOrchestratorImpl) PipelineExists(name string) (bool, error) {

pkg/pipeline/PipelineBuilder.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1921,7 +1921,7 @@ func (impl PipelineBuilderImpl) DeleteCdPipeline(pipeline *pipelineConfig.Pipeli
19211921
}
19221922
// Rollback tx on error.
19231923
defer tx.Rollback()
1924-
if err = impl.ciCdPipelineOrchestrator.DeleteCdPipeline(pipeline.Id, tx); err != nil {
1924+
if err = impl.ciCdPipelineOrchestrator.DeleteCdPipeline(pipeline.Id, userId, tx); err != nil {
19251925
impl.logger.Errorw("err in deleting pipeline from db", "id", pipeline, "err", err)
19261926
return err
19271927
}
@@ -4269,7 +4269,7 @@ func (impl PipelineBuilderImpl) MarkGitOpsDevtronAppsDeletedWhereArgoAppIsDelete
42694269
}
42704270
impl.logger.Warnw("app not found in argo, deleting from db ", "err", err)
42714271
//make call to delete it from pipeline DB because it's ACD counterpart is deleted
4272-
err = impl.DeleteCdPipeline(pipeline, context.Background(), true, false, 0)
4272+
err = impl.DeleteCdPipeline(pipeline, context.Background(), true, false, 1)
42734273
if err != nil {
42744274
impl.logger.Errorw("error in deleting cd pipeline", "err", err)
42754275
return acdAppFound, err

0 commit comments

Comments
 (0)