Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: change CI backend infra #4251

Merged
merged 71 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from 59 commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
b6bb570
wip
gireesh-devtron Nov 7, 2023
ba29a23
wip
gireesh-devtron Nov 7, 2023
a1ae345
wip
gireesh-devtron Nov 7, 2023
005cec1
added change ci functionalities from all pipeline to all other pipeli…
gireesh-devtron Nov 7, 2023
820e527
added change ci from any ci-pipeline to external ci
gireesh-devtron Nov 7, 2023
c4e331f
add nil ptr check
gireesh-devtron Nov 8, 2023
05da314
comments added
gireesh-devtron Nov 8, 2023
0b35542
delete ci-pipeline code added
adi6859 Nov 8, 2023
551b7cf
function renamed
adi6859 Nov 8, 2023
1d62abb
merge delete ci-pipeline logic
gireesh-devtron Nov 8, 2023
8cbfe9b
some refactoring done around ciMaterial
adi6859 Nov 8, 2023
e0bc5a1
nil pointer handled
adi6859 Nov 8, 2023
b72f5a7
code refactoring
adi6859 Nov 9, 2023
bc22891
wip
gireesh-devtron Nov 8, 2023
2525305
Merge branch 'main' into change-ci-pipeline-feat
subhashish-devtron Nov 9, 2023
a19c8f6
delete functionality fixes
gireesh-devtron Nov 9, 2023
e1c3ede
query fix
gireesh-devtron Nov 9, 2023
d73d2ab
query fix
gireesh-devtron Nov 9, 2023
43bbf4b
fixes
gireesh-devtron Nov 9, 2023
ac336c7
material delete fix
subhashish-devtron Nov 9, 2023
c657888
fix
gireesh-devtron Nov 9, 2023
07f8820
workflow existstence check made conditional
gireesh-devtron Nov 9, 2023
a8fd850
sending prod env flag in cdpipelines response
gireesh-devtron Nov 14, 2023
444b3be
fixes
gireesh-devtron Nov 15, 2023
ccbeb69
linked cd count fix
subhashish-devtron Nov 9, 2023
f346754
Merge remote-tracking branch 'origin/main' into change-ci-pipeline-feat
subhashish-devtron Nov 16, 2023
dc24b86
made delete templateOverride conditional for linked ci's
gireesh-devtron Nov 16, 2023
0945d7c
ci change handling for linkedCD type in delete
subhashish-devtron Nov 16, 2023
de6afdc
fix
gireesh-devtron Nov 16, 2023
2ddaae6
Merge branch 'main' into change-ci-pipeline-feat
gireesh-devtron Nov 16, 2023
5023c8e
allow switch to external ci in all cases
gireesh-devtron Nov 16, 2023
1bc923c
remove required tag
gireesh-devtron Nov 16, 2023
5ebbfe9
make pipeline creation optional incase of external ci creation
gireesh-devtron Nov 17, 2023
cca7788
skip some pipeline creation validations if envId is not set in pipeline
gireesh-devtron Nov 17, 2023
0b79344
shadowed pipelineid fix
gireesh-devtron Nov 17, 2023
6d5b2bf
sync
subhashish-devtron Nov 17, 2023
152150c
fix
gireesh-devtron Nov 17, 2023
1192650
addressed comments
subhashish-devtron Nov 17, 2023
252bff4
block new external-ci creation in existing wf unless it's a switch ci…
gireesh-devtron Nov 17, 2023
ea569be
remove unused condition
gireesh-devtron Nov 20, 2023
0114589
remove duplicate flags
gireesh-devtron Nov 20, 2023
66bfac2
move switch ci pipeline logic to separate function
gireesh-devtron Nov 20, 2023
611eac6
Merge branch 'main' into change-ci-pipeline-feat
gireesh-devtron Nov 20, 2023
1c09f80
fix
gireesh-devtron Nov 20, 2023
8edd21b
migrartion-linked-cd
subhashish-devtron Nov 20, 2023
c7ed823
Merge branch 'main' into change-ci-pipeline-feat
subhashish-devtron Nov 21, 2023
e79fa7c
bump script
subhashish-devtron Nov 21, 2023
9f8edf9
merge main
gireesh-devtron Nov 22, 2023
c91b69a
bump sql script version
gireesh-devtron Nov 22, 2023
ed28503
fix
gireesh-devtron Nov 22, 2023
b7a92fc
duplicate external-ci and wfmapping creation fix
gireesh-devtron Nov 24, 2023
948c9e7
Merge branch 'main' into change-ci-pipeline-feat
gireesh-devtron Nov 24, 2023
3c5fa1a
script number bump
gireesh-devtron Nov 24, 2023
9ac7abd
Merge remote-tracking branch 'origin/main' into change-ci-pipeline-feat
subhashish-devtron Nov 27, 2023
c37fd32
bump script
subhashish-devtron Nov 27, 2023
18fa7ca
Merge remote-tracking branch 'origin/main' into linked-cd-refactor
subhashish-devtron Nov 27, 2023
3e62777
merge
subhashish-devtron Nov 27, 2023
d2d336f
merge
subhashish-devtron Nov 27, 2023
22f4eaf
Merge branch 'change-ci-pipeline-feat' into linked-cd-refactor
subhashish-devtron Nov 27, 2023
1042796
pr comments
subhashish-devtron Nov 29, 2023
d632ae8
extract out switch ciPipeline logic to separate ci pipeline switch se…
gireesh-devtron Nov 29, 2023
81a6184
merge main
gireesh-devtron Nov 29, 2023
550bf1c
removing rbac for switch ci
subhashish-devtron Nov 29, 2023
03bb53d
Merge remote-tracking branch 'origin/main' into linked-cd-refactor
subhashish-devtron Nov 29, 2023
cbce01e
review comments incorporated
gireesh-devtron Nov 29, 2023
2e07959
Merge remote-tracking branch 'origin/linked-cd-refactor' into linked-…
gireesh-devtron Nov 29, 2023
34c4261
refactor
gireesh-devtron Nov 29, 2023
efa9f5a
fix
gireesh-devtron Nov 29, 2023
ec9c737
Merge remote-tracking branch 'origin/main' into linked-cd-refactor
subhashish-devtron Nov 30, 2023
925ab62
merge main
gireesh-devtron Nov 30, 2023
fdab78a
Merge remote-tracking branch 'origin/linked-cd-refactor' into linked-…
gireesh-devtron Nov 30, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions api/bean/AppView.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ type DeploymentDetailContainer struct {
Deprecated bool `json:"deprecated"`
K8sVersion string `json:"k8sVersion"`
CiArtifactId int `json:"ciArtifactId"`
ParentArtifactId int `json:"parentArtifactId"`
ClusterId int `json:"clusterId"`
DeploymentAppType string `json:"deploymentAppType"`
CiPipelineId int `json:"-"`
Expand Down
2 changes: 1 addition & 1 deletion api/restHandler/app/BuildPipelineRestHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -1101,7 +1101,7 @@ func (handler PipelineConfigRestHandlerImpl) GetCIPipelineById(w http.ResponseWr
if handler.appWorkflowService.CheckCdPipelineByCiPipelineId(pipelineId) {
for _, envId := range environmentIds {
envObject := handler.enforcerUtil.GetEnvRBACNameByCiPipelineIdAndEnvId(pipelineId, envId)
if ok := handler.enforcer.Enforce(token, casbin.ResourceEnvironment, casbin.ActionUpdate, envObject); !ok {
if ok := handler.enforcer.Enforce(token, casbin.ResourceEnvironment, casbin.ActionGet, envObject); !ok {
common.WriteJsonResp(w, fmt.Errorf("unauthorized user"), "Unauthorized User", http.StatusForbidden)
return
}
Expand Down
21 changes: 15 additions & 6 deletions api/restHandler/app/DeploymentPipelineRestHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
resourceGroup2 "github.com/devtron-labs/devtron/pkg/resourceGroup"
"github.com/devtron-labs/devtron/pkg/resourceQualifiers"
"github.com/devtron-labs/devtron/pkg/user/casbin"
"github.com/devtron-labs/devtron/pkg/variables/models"
util2 "github.com/devtron-labs/devtron/util"
"github.com/go-pg/pg"
"github.com/gorilla/mux"
Expand Down Expand Up @@ -214,11 +215,14 @@ func (handler PipelineConfigRestHandlerImpl) CreateCdPipeline(w http.ResponseWri
return
}
for _, deploymentPipeline := range cdPipeline.Pipelines {
object := handler.enforcerUtil.GetAppRBACByAppNameAndEnvId(app.AppName, deploymentPipeline.EnvironmentId)
handler.Logger.Debugw("Triggered Request By:", "object", object)
if ok := handler.enforcer.Enforce(token, casbin.ResourceEnvironment, casbin.ActionCreate, object); !ok {
common.WriteJsonResp(w, fmt.Errorf("unauthorized user"), "Unauthorized User", http.StatusForbidden)
return
//if pipeline is of switch ci , then conform how to enforce rbac
if deploymentPipeline.EnvironmentId > 0 {
object := handler.enforcerUtil.GetAppRBACByAppNameAndEnvId(app.AppName, deploymentPipeline.EnvironmentId)
handler.Logger.Debugw("Triggered Request By:", "object", object)
if ok := handler.enforcer.Enforce(token, casbin.ResourceEnvironment, casbin.ActionCreate, object); !ok {
common.WriteJsonResp(w, fmt.Errorf("unauthorized user"), "Unauthorized User", http.StatusForbidden)
return
}
}
}
//RBAC
Expand Down Expand Up @@ -325,7 +329,12 @@ func (handler PipelineConfigRestHandlerImpl) PatchCdPipeline(w http.ResponseWrit
createResp, err := handler.pipelineBuilder.PatchCdPipelines(&cdPipeline, ctx)
if err != nil {
handler.Logger.Errorw("service err, PatchCdPipeline", "err", err, "payload", cdPipeline)
common.WriteJsonResp(w, err, nil, http.StatusInternalServerError)

if errors.As(err, &models.ValidationError{}) {
common.WriteJsonResp(w, err, nil, http.StatusPreconditionFailed)
} else {
common.WriteJsonResp(w, err, nil, http.StatusInternalServerError)
}
return
}
common.WriteJsonResp(w, err, createResp, http.StatusOK)
Expand Down
2 changes: 1 addition & 1 deletion api/restHandler/app/PipelineConfigRestHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ import (
)

type PipelineRestHandlerEnvConfig struct {
UseArtifactListApiV2 bool `env:"USE_ARTIFACT_LISTING_API_V2"`
UseArtifactListApiV2 bool `env:"USE_ARTIFACT_LISTING_API_V2" envDefault:"true"`
}

type DevtronAppRestHandler interface {
Expand Down
1 change: 1 addition & 0 deletions internal/sql/repository/AppListingRepository.go
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ func (impl AppListingRepositoryImpl) deploymentDetailsByAppIdAndEnvId(ctx contex
" p.deployment_app_delete_request," +
" cia.data_source," +
" cia.id as ci_artifact_id," +
" cia.parent_ci_artifact as parent_artifact_id," +
" cl.k8s_version," +
" env.cluster_id," +
" env.is_virtual_environment," +
Expand Down
32 changes: 30 additions & 2 deletions internal/sql/repository/CiArtifactRepository.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,9 @@ type CiArtifactRepository interface {
GetLatestArtifactTimeByCiPipelineId(ciPipelineId int) (*CiArtifact, error)
GetArtifactsByCDPipelineV2(cdPipelineId int) ([]CiArtifact, error)
GetArtifactsByCDPipelineAndRunnerType(cdPipelineId int, runnerType bean.WorkflowType) ([]CiArtifact, error)
SaveAll(artifacts []*CiArtifact) error
SaveAll(artifacts []*CiArtifact) ([]*CiArtifact, error)
GetArtifactsByCiPipelineId(ciPipelineId int) ([]CiArtifact, error)
GetArtifactsByCiPipelineIds(ciPipelineIds []int) ([]CiArtifact, error)
FinDByParentCiArtifactAndCiId(parentCiArtifact int, ciPipelineIds []int) ([]*CiArtifact, error)
GetLatest(cdPipelineId int) (int, error)
GetByImageDigest(imageDigest string) (artifact *CiArtifact, err error)
Expand All @@ -104,6 +105,8 @@ type CiArtifactRepository interface {
FindArtifactByListFilter(listingFilterOptions *bean.ArtifactsListFilterOptions) ([]CiArtifact, int, error)
GetArtifactsByDataSourceAndComponentId(dataSource string, componentId int) ([]CiArtifact, error)
FindCiArtifactByImagePaths(images []string) ([]CiArtifact, error)

UpdateLatestTimestamp(artifactIds []int) error
}

type CiArtifactRepositoryImpl struct {
Expand All @@ -115,7 +118,7 @@ func NewCiArtifactRepositoryImpl(dbConnection *pg.DB, logger *zap.SugaredLogger)
return &CiArtifactRepositoryImpl{dbConnection: dbConnection, logger: logger}
}

func (impl CiArtifactRepositoryImpl) SaveAll(artifacts []*CiArtifact) error {
func (impl CiArtifactRepositoryImpl) SaveAll(artifacts []*CiArtifact) ([]*CiArtifact, error) {
err := impl.dbConnection.RunInTransaction(func(tx *pg.Tx) error {
for _, ciArtifact := range artifacts {
r, err := tx.Model(ciArtifact).Insert()
Expand All @@ -126,6 +129,17 @@ func (impl CiArtifactRepositoryImpl) SaveAll(artifacts []*CiArtifact) error {
}
return nil
})
return artifacts, err
}

func (impl CiArtifactRepositoryImpl) UpdateLatestTimestamp(artifactIds []int) error {
if len(artifactIds) == 0 {
return nil
subhashish-devtron marked this conversation as resolved.
Show resolved Hide resolved
}
_, err := impl.dbConnection.Model(&CiArtifact{}).
Set("updated_on = ?", time.Now()).
Where("id IN (?)", pg.In(artifactIds)).
Update()
return err
}

Expand Down Expand Up @@ -602,6 +616,20 @@ func (impl CiArtifactRepositoryImpl) GetArtifactsByCiPipelineId(ciPipelineId int
return artifacts, err
}

func (impl CiArtifactRepositoryImpl) GetArtifactsByCiPipelineIds(ciPipelineIds []int) ([]CiArtifact, error) {
var artifacts []CiArtifact
subhashish-devtron marked this conversation as resolved.
Show resolved Hide resolved
err := impl.dbConnection.
Model(&artifacts).
Column("ci_artifact.*").
Join("INNER JOIN ci_pipeline cp on cp.id=ci_artifact.pipeline_id").
Where("cp.id in (?)", pg.In(ciPipelineIds)).
Where("cp.deleted = ?", false).
Order("ci_artifact.id DESC").
Select()

return artifacts, err
}

func (impl CiArtifactRepositoryImpl) FinDByParentCiArtifactAndCiId(parentCiArtifact int, ciPipelineIds []int) ([]*CiArtifact, error) {
var CiArtifacts []*CiArtifact
err := impl.dbConnection.
Expand Down
27 changes: 27 additions & 0 deletions internal/sql/repository/appWorkflow/AppWorkflowRepository.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ type AppWorkflowRepository interface {
FindByCDPipelineIds(cdPipelineIds []int) ([]*AppWorkflowMapping, error)
FindByWorkflowIds(workflowIds []int) ([]*AppWorkflowMapping, error)
FindMappingByAppIds(appIds []int) ([]*AppWorkflowMapping, error)
UpdateParentComponentDetails(tx *pg.Tx, oldComponentId int, oldComponentType string, newComponentId int, newComponentType string) error
FindWFMappingByComponent(componentType string, componentId int) (*AppWorkflowMapping, error)
}

type AppWorkflowRepositoryImpl struct {
Expand Down Expand Up @@ -411,6 +413,15 @@ func (impl AppWorkflowRepositoryImpl) FindWFCDMappingByExternalCiId(externalCiId
Select()
return models, err
}
func (impl AppWorkflowRepositoryImpl) FindWFMappingByComponent(componentType string, componentId int) (*AppWorkflowMapping, error) {
model := AppWorkflowMapping{}
err := impl.dbConnection.Model(&model).
Where("type = ?", componentType).
Where("component_id = ?", componentId).
Where("active = ?", true).
Select()
return &model, err
}

func (impl AppWorkflowRepositoryImpl) FindWFCDMappingByExternalCiIdByIdsIn(externalCiId []int) ([]*AppWorkflowMapping, error) {
var models []*AppWorkflowMapping
Expand Down Expand Up @@ -461,3 +472,19 @@ func (impl AppWorkflowRepositoryImpl) FindMappingByAppIds(appIds []int) ([]*AppW
Select()
return appWorkflowsMapping, err
}

func (impl AppWorkflowRepositoryImpl) UpdateParentComponentDetails(tx *pg.Tx, oldParentId int, oldParentType string, newParentId int, newParentType string) error {

/*updateQuery := fmt.Sprintf(" UPDATE app_workflow_mapping "+
" SET parent_type = (select type from new_app_workflow_mapping),parent_id = (select id from new_app_workflow_mapping) where parent_id = %v and parent_type='%v' and active = true", oldComponentId, oldComponentType)

finalQuery := withQuery + updateQuery*/
_, err := tx.Model((*AppWorkflowMapping)(nil)).
Set("parent_type = ?", newParentType).
Set("parent_id = ?", newParentId).
Where("parent_type = ?", oldParentType).
Where("parent_id = ?", oldParentId).
Where("active = true").
Update()
return err
}
31 changes: 29 additions & 2 deletions internal/sql/repository/pipelineConfig/CiPipelineRepository.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ type CiPipelineScript struct {
}

type CiPipelineRepository interface {
sql.TransactionWrapper
Save(pipeline *CiPipeline, tx *pg.Tx) error
SaveCiEnvMapping(cienvmapping *CiEnvMapping, tx *pg.Tx) error
SaveExternalCi(pipeline *ExternalCiPipeline, tx *pg.Tx) (*ExternalCiPipeline, error)
Expand Down Expand Up @@ -112,6 +113,7 @@ type CiPipelineRepository interface {
FindByName(pipelineName string) (pipeline *CiPipeline, err error)
CheckIfPipelineExistsByNameAndAppId(pipelineName string, appId int) (bool, error)
FindByParentCiPipelineId(parentCiPipelineId int) ([]*CiPipeline, error)
FindByParentIdAndType(parentCiPipelineId int, pipelineType string) ([]*CiPipeline, error)

FetchParentCiPipelinesForDG() ([]*CiPipelinesMap, error)
FetchCiPipelinesForDG(parentId int, childCiPipelineIds []int) (*CiPipeline, int, error)
Expand All @@ -125,16 +127,19 @@ type CiPipelineRepository interface {
FindAppIdsForCiPipelineIds(pipelineIds []int) (map[int]int, error)
GetCiPipelineByArtifactId(artifactId int) (*CiPipeline, error)
GetExternalCiPipelineByArtifactId(artifactId int) (*ExternalCiPipeline, error)
FindLinkedCiCount(ciPipelineId int) (int, error)
}
type CiPipelineRepositoryImpl struct {
dbConnection *pg.DB
logger *zap.SugaredLogger
*sql.TransactionUtilImpl
}

func NewCiPipelineRepositoryImpl(dbConnection *pg.DB, logger *zap.SugaredLogger) *CiPipelineRepositoryImpl {
return &CiPipelineRepositoryImpl{
dbConnection: dbConnection,
logger: logger,
dbConnection: dbConnection,
logger: logger,
TransactionUtilImpl: sql.NewTransactionUtilImpl(dbConnection),
}
}

Expand All @@ -147,6 +152,16 @@ func (impl CiPipelineRepositoryImpl) FindByParentCiPipelineId(parentCiPipelineId
return ciPipelines, err
}

func (impl CiPipelineRepositoryImpl) FindByParentIdAndType(parentCiPipelineId int, pipelineType string) ([]*CiPipeline, error) {
var ciPipelines []*CiPipeline
err := impl.dbConnection.Model(&ciPipelines).
Where("parent_ci_pipeline = ?", parentCiPipelineId).
Where("ci_pipeline_type = ?", pipelineType).
Where("active = ?", true).
Select()
return ciPipelines, err
}

func (impl CiPipelineRepositoryImpl) FindByIdsIn(ids []int) ([]*CiPipeline, error) {
var ciPipelines []*CiPipeline
err := impl.dbConnection.Model(&ciPipelines).
Expand Down Expand Up @@ -552,3 +567,15 @@ func (impl CiPipelineRepositoryImpl) FindCiPipelineByAppIdAndEnvIds(appId int, e
_, err := impl.dbConnection.Query(&pipelines, query, appId, pg.In(envIds))
return pipelines, err
}

func (impl CiPipelineRepositoryImpl) FindLinkedCiCount(ciPipelineId int) (int, error) {
pipeline := &CiPipeline{}
cnt, err := impl.dbConnection.Model(pipeline).
Where("parent_ci_pipeline = ?", ciPipelineId).
Where("deleted = ?", false).
Count()
if err == pg.ErrNoRows {
return 0, nil
}
return cnt, err
}
12 changes: 12 additions & 0 deletions internal/sql/repository/pipelineConfig/CiWorkflowRepository.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ type CiWorkflowRepository interface {
ExistsByStatus(status string) (bool, error)
FindBuildTypeAndStatusDataOfLast1Day() []*BuildTypeCount
FIndCiWorkflowStatusesByAppId(appId int) ([]*CiWorkflowStatus, error)
FindRunningWorkflowCount(ciPipelineId int) (int, error)
}

type CiWorkflowRepositoryImpl struct {
Expand Down Expand Up @@ -351,3 +352,14 @@ func (impl *CiWorkflowRepositoryImpl) FIndCiWorkflowStatusesByAppId(appId int) (
}
return ciworkflowStatuses, err
}

func (impl *CiWorkflowRepositoryImpl) FindRunningWorkflowCount(ciPipelineId int) (int, error) {
cnt, err := impl.dbConnection.Model((*CiWorkflow)(nil)).
Where("status IN (?)", pg.In([]string{"Running", "Starting"})).
Where("ci_pipeline_id = ?", ciPipelineId).
Count()
if err == pg.ErrNoRows {
return 0, nil
}
return cnt, err
}
13 changes: 13 additions & 0 deletions internal/sql/repository/pipelineConfig/PipelineRepository.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"github.com/devtron-labs/devtron/pkg/sql"
"github.com/go-pg/pg"
"go.uber.org/zap"
"k8s.io/utils/pointer"
"strconv"
"time"
)
Expand Down Expand Up @@ -110,6 +111,7 @@ type PipelineRepository interface {
FindActiveByAppIds(appIds []int) (pipelines []*Pipeline, err error)
FindAppAndEnvironmentAndProjectByPipelineIds(pipelineIds []int) (pipelines []*Pipeline, err error)
FilterDeploymentDeleteRequestedPipelineIds(cdPipelineIds []int) (map[int]bool, error)
UpdateOldCiPipelineIdToNewCiPipelineId(tx *pg.Tx, oldCiPipelineId, newCiPipelineId int) error
}

type CiArtifactDTO struct {
Expand Down Expand Up @@ -670,3 +672,14 @@ func (impl PipelineRepositoryImpl) FilterDeploymentDeleteRequestedPipelineIds(cd
}
return pipelineIdsMap, nil
}

func (impl PipelineRepositoryImpl) UpdateOldCiPipelineIdToNewCiPipelineId(tx *pg.Tx, oldCiPipelineId, newCiPipelineId int) error {
newCiPipId := pointer.Int(newCiPipelineId)
if newCiPipelineId == 0 {
newCiPipId = nil
}
_, err := tx.Model((*Pipeline)(nil)).Set("ci_pipeline_id = ?", newCiPipId).
Where("ci_pipeline_id = ? ", oldCiPipelineId).
Where("deleted = ?", false).Update()
return err
}