Skip to content

Commit 96a2471

Browse files
authored
Merge branch 'main' into deployment-tempalte-history-fix
2 parents 778824f + ad89c1d commit 96a2471

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

internal/sql/repository/pipelineConfig/CiTemplateOverrideRepository.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,9 @@ func (repo *CiTemplateOverrideRepositoryImpl) FindByCiPipelineId(ciPipelineId in
129129
}
130130

131131
func (repo *CiTemplateOverrideRepositoryImpl) FindIfTemplateOverrideExistsByCiPipelineIdsAndGitMaterialId(ciPipelineIds []int, gitMaterialId int) (bool, error) {
132+
if len(ciPipelineIds) == 0 {
133+
return false, nil
134+
}
132135
count, err := repo.dbConnection.Model((*CiTemplateOverride)(nil)).
133136
Where("ci_pipeline_id in (?)", pg.In(ciPipelineIds)).
134137
WhereGroup(func(q *orm.Query) (*orm.Query, error) {

pkg/pipeline/CiMaterialConfigService.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import (
2727
"github.com/devtron-labs/devtron/pkg/build/pipeline"
2828
"github.com/devtron-labs/devtron/pkg/pipeline/history"
2929
"github.com/devtron-labs/devtron/pkg/sql"
30-
"github.com/devtron-labs/devtron/util/sliceUtil"
3130
"github.com/go-pg/pg"
3231
"github.com/juju/errors"
3332
"go.uber.org/zap"
@@ -126,12 +125,15 @@ func (impl *CiMaterialConfigServiceImpl) DeleteMaterial(request *bean.UpdateMate
126125
return fmt.Errorf("cannot delete git material, is being used in docker config")
127126
}
128127
}
129-
pipelineIds := sliceUtil.NewSliceFromFuncExec(pipelines, func(dbPipeline *pipelineConfig.CiPipeline) int {
130-
return dbPipeline.Id
131-
})
132-
exist, err := impl.ciTemplateService.CheckIfTemplateOverrideExists(pipelineIds, request.Material.Id)
128+
overriddenPipelineIds := make([]int, 0, len(pipelines))
129+
for _, dbPipeline := range pipelines {
130+
if dbPipeline.IsDockerConfigOverridden {
131+
overriddenPipelineIds = append(overriddenPipelineIds, dbPipeline.Id)
132+
}
133+
}
134+
exist, err := impl.ciTemplateService.CheckIfTemplateOverrideExists(overriddenPipelineIds, request.Material.Id)
133135
if err != nil {
134-
impl.logger.Errorw("error in checking if template override exists", "pipelineIds", pipelineIds, "gitMaterialId", request.Material.Id, "err", err)
136+
impl.logger.Errorw("error in checking if template override exists", "pipelineIds", overriddenPipelineIds, "gitMaterialId", request.Material.Id, "err", err)
135137
return err
136138
}
137139
if exist {

0 commit comments

Comments
 (0)