@@ -42,7 +42,7 @@ type PipelineConfigRepository interface {
42
42
FindByStrategyAndPipelineId (strategy chartRepoRepository.DeploymentStrategy , pipelineId int ) (pipelineStrategy * PipelineStrategy , err error )
43
43
GetAllStrategyByPipelineId (pipelineId int ) ([]* PipelineStrategy , error )
44
44
GetDefaultStrategyByPipelineId (pipelineId int ) (pipelineStrategy * PipelineStrategy , err error )
45
- Delete (pipelineStrategy * PipelineStrategy , tx * pg.Tx ) error
45
+ MarkAsDeleted (pipelineStrategy * PipelineStrategy , userId int32 , tx * pg.Tx ) error
46
46
GetAllStrategyByPipelineIds (pipelineIds []int ) ([]* PipelineStrategy , error )
47
47
}
48
48
@@ -59,33 +59,41 @@ func (impl PipelineConfigRepositoryImpl) Save(pipelineStrategy *PipelineStrategy
59
59
}
60
60
61
61
func (impl PipelineConfigRepositoryImpl ) Update (pipelineStrategy * PipelineStrategy , tx * pg.Tx ) error {
62
- _ , err := impl . dbConnection .Model (pipelineStrategy ).WherePK ().UpdateNotNull ()
62
+ _ , err := tx .Model (pipelineStrategy ).WherePK ().UpdateNotNull ()
63
63
return err
64
64
}
65
65
66
66
func (impl PipelineConfigRepositoryImpl ) FindById (id int ) (pipelineStrategy * PipelineStrategy , err error ) {
67
67
pipelineStrategy = & PipelineStrategy {}
68
68
err = impl .dbConnection .Model (pipelineStrategy ).
69
- Where ("id = ?" , id ).Select ()
69
+ Where ("id = ?" , id ).
70
+ Where ("deleted = ?" , false ).
71
+ Select ()
70
72
return pipelineStrategy , err
71
73
}
72
74
73
75
func (impl PipelineConfigRepositoryImpl ) FindByStrategy (strategy chartRepoRepository.DeploymentStrategy ) (pipelineStrategy * PipelineStrategy , err error ) {
74
76
pipelineStrategy = & PipelineStrategy {}
75
77
err = impl .dbConnection .Model (pipelineStrategy ).
76
- Where ("strategy = ?" , strategy ).Select ()
78
+ Where ("strategy = ?" , strategy ).
79
+ Where ("deleted = ?" , false ).
80
+ Select ()
77
81
return pipelineStrategy , err
78
82
}
79
83
80
84
func (impl PipelineConfigRepositoryImpl ) FindByStrategyAndPipelineId (strategy chartRepoRepository.DeploymentStrategy , pipelineId int ) (pipelineStrategy * PipelineStrategy , err error ) {
81
85
pipelineStrategy = & PipelineStrategy {}
82
86
err = impl .dbConnection .Model (pipelineStrategy ).
83
87
Where ("strategy = ?" , strategy ).
84
- Where ("pipeline_id = ?" , pipelineId ).Select ()
88
+ Where ("pipeline_id = ?" , pipelineId ).
89
+ Where ("deleted = ?" , false ).
90
+ Select ()
85
91
return pipelineStrategy , err
86
92
}
87
93
88
- // it will return for multiple pipeline config for pipeline, per pipeline single pipeline config(blue green, canary)
94
+ // GetAllStrategyByPipelineId -
95
+ // it will return for multiple pipeline strategies for a pipeline
96
+ // per pipeline single pipeline strategy (BLUE_GREEN, CANARY, ROLLING, RECREATE) can be there
89
97
func (impl PipelineConfigRepositoryImpl ) GetAllStrategyByPipelineId (pipelineId int ) ([]* PipelineStrategy , error ) {
90
98
var pipelineStrategies []* PipelineStrategy
91
99
err := impl .dbConnection .
@@ -99,7 +107,8 @@ func (impl PipelineConfigRepositoryImpl) GetAllStrategyByPipelineId(pipelineId i
99
107
return pipelineStrategies , err
100
108
}
101
109
102
- // it will return single latest pipeline config for requested pipeline
110
+ // GetDefaultStrategyByPipelineId -
111
+ // it will return single latest pipeline strategy for the requested pipeline
103
112
func (impl PipelineConfigRepositoryImpl ) GetDefaultStrategyByPipelineId (pipelineId int ) (pipelineStrategy * PipelineStrategy , err error ) {
104
113
pipelineStrategy = & PipelineStrategy {}
105
114
err = impl .dbConnection .
@@ -114,8 +123,12 @@ func (impl PipelineConfigRepositoryImpl) GetDefaultStrategyByPipelineId(pipeline
114
123
return pipelineStrategy , err
115
124
}
116
125
117
- func (impl PipelineConfigRepositoryImpl ) Delete (pipelineStrategy * PipelineStrategy , tx * pg.Tx ) error {
118
- return tx .Delete (pipelineStrategy )
126
+ // MarkAsDeleted -
127
+ // it will soft-delete the pipeline strategy from the database
128
+ func (impl PipelineConfigRepositoryImpl ) MarkAsDeleted (pipelineStrategy * PipelineStrategy , userId int32 , tx * pg.Tx ) error {
129
+ pipelineStrategy .Deleted = true
130
+ pipelineStrategy .UpdateAuditLog (userId )
131
+ return impl .Update (pipelineStrategy , tx )
119
132
}
120
133
121
134
func (impl PipelineConfigRepositoryImpl ) GetAllStrategyByPipelineIds (pipelineIds []int ) ([]* PipelineStrategy , error ) {
0 commit comments