Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ func (repo *CiTemplateOverrideRepositoryImpl) FindByCiPipelineId(ciPipelineId in
}

func (repo *CiTemplateOverrideRepositoryImpl) FindIfTemplateOverrideExistsByCiPipelineIdsAndGitMaterialId(ciPipelineIds []int, gitMaterialId int) (bool, error) {
if len(ciPipelineIds) == 0 {
return false, nil
}
count, err := repo.dbConnection.Model((*CiTemplateOverride)(nil)).
Where("ci_pipeline_id in (?)", pg.In(ciPipelineIds)).
WhereGroup(func(q *orm.Query) (*orm.Query, error) {
Expand Down
14 changes: 8 additions & 6 deletions pkg/pipeline/CiMaterialConfigService.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
"github.com/devtron-labs/devtron/pkg/build/pipeline"
"github.com/devtron-labs/devtron/pkg/pipeline/history"
"github.com/devtron-labs/devtron/pkg/sql"
"github.com/devtron-labs/devtron/util/sliceUtil"
"github.com/go-pg/pg"
"github.com/juju/errors"
"go.uber.org/zap"
Expand Down Expand Up @@ -126,12 +125,15 @@ func (impl *CiMaterialConfigServiceImpl) DeleteMaterial(request *bean.UpdateMate
return fmt.Errorf("cannot delete git material, is being used in docker config")
}
}
pipelineIds := sliceUtil.NewSliceFromFuncExec(pipelines, func(dbPipeline *pipelineConfig.CiPipeline) int {
return dbPipeline.Id
})
exist, err := impl.ciTemplateService.CheckIfTemplateOverrideExists(pipelineIds, request.Material.Id)
overriddenPipelineIds := make([]int, 0, len(pipelines))
for _, dbPipeline := range pipelines {
if dbPipeline.IsDockerConfigOverridden {
overriddenPipelineIds = append(overriddenPipelineIds, dbPipeline.Id)
}
}
exist, err := impl.ciTemplateService.CheckIfTemplateOverrideExists(overriddenPipelineIds, request.Material.Id)
if err != nil {
impl.logger.Errorw("error in checking if template override exists", "pipelineIds", pipelineIds, "gitMaterialId", request.Material.Id, "err", err)
impl.logger.Errorw("error in checking if template override exists", "pipelineIds", overriddenPipelineIds, "gitMaterialId", request.Material.Id, "err", err)
return err
}
if exist {
Expand Down
Loading