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

fix: old custom tag migration #4273

Merged
merged 4 commits into from
Nov 23, 2023
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
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';
Loading