Skip to content

Commit

Permalink
fix: old custom tag migration (#4273)
Browse files Browse the repository at this point in the history
* handling migration for old customt ag

* fix custom tag ci enable/disable

* copy container image plugin image update
  • Loading branch information
iamayushm committed Nov 23, 2023
1 parent 6afbd30 commit 677aa7a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
12 changes: 10 additions & 2 deletions pkg/pipeline/CiCdPipelineOrchestrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ func (impl CiCdPipelineOrchestratorImpl) PatchMaterialValue(createRequest *bean.

//If customTagObject has been passed, create or update the resource
//Otherwise deleteIfExists
if len(createRequest.CustomTagObject.TagPattern) > 0 {
if createRequest.CustomTagObject != nil && len(createRequest.CustomTagObject.TagPattern) > 0 {
customTag := bean4.CustomTag{
EntityKey: bean2.EntityTypeCiPipelineId,
EntityValue: strconv.Itoa(ciPipelineObject.Id),
Expand Down Expand Up @@ -776,7 +776,15 @@ func (impl CiCdPipelineOrchestratorImpl) CreateCiConf(createRequest *bean.CiConf
}

//If customTagObejct has been passed, save it
if ciPipeline.CustomTagObject != nil && len(ciPipeline.CustomTagObject.TagPattern) != 0 {
if !ciPipeline.EnableCustomTag {
err := impl.customTagService.DisableCustomTagIfExist(bean4.CustomTag{
EntityKey: bean2.EntityTypeCiPipelineId,
EntityValue: strconv.Itoa(ciPipeline.Id),
})
if err != nil {
return nil, err
}
} else if ciPipeline.CustomTagObject != nil && len(ciPipeline.CustomTagObject.TagPattern) != 0 {
customTag := &bean4.CustomTag{
EntityKey: bean2.EntityTypeCiPipelineId,
EntityValue: strconv.Itoa(ciPipeline.Id),
Expand Down
2 changes: 1 addition & 1 deletion pkg/pipeline/CustomTagService.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (impl *CustomTagServiceImpl) CreateOrUpdateCustomTag(tag *bean.CustomTag) e
AutoIncreasingNumber: tag.AutoIncreasingNumber,
Metadata: tag.Metadata,
Active: true,
Enabled: true,
Enabled: tag.Enabled,
}
oldTagObject, err := impl.customTagRepository.FetchCustomTagData(customTagData.EntityKey, customTagData.EntityValue)
if err != nil && err != pg.ErrNoRows {
Expand Down
1 change: 1 addition & 0 deletions scripts/sql/192_custom_tag_migration.down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
update custom_tag set enabled=false where active=true;
3 changes: 3 additions & 0 deletions scripts/sql/192_custom_tag_migration.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
update custom_tag set enabled=true where active=true;
update plugin_pipeline_script set container_image_path ='quay.io/devtron/copy-container-images:48bdcbb4-567-19597'
where container_image_path ='quay.io/devtron/copy-container-images:7285439d-567-19519';

0 comments on commit 677aa7a

Please sign in to comment.