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: updated ci_artifact.data_source migration condition #4548

Merged
merged 1 commit into from
Jan 16, 2024
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
9 changes: 9 additions & 0 deletions internal/sql/repository/CiArtifactRepository.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"fmt"
"github.com/devtron-labs/devtron/internal/sql/repository/helper"
"github.com/devtron-labs/devtron/pkg/sql"
"golang.org/x/exp/slices"
"strings"
"time"

Expand Down Expand Up @@ -84,6 +85,14 @@ type CiArtifact struct {
sql.AuditLog
}

func (c *CiArtifact) IsMigrationRequired() bool {
validDataSourceTypeList := []string{CI_RUNNER, WEBHOOK, PRE_CD, POST_CD, POST_CI, GOCD}
if slices.Contains(validDataSourceTypeList, c.DataSource) {
return false
}
return true
}

type CiArtifactRepository interface {
Save(artifact *CiArtifact) error
Delete(artifact *CiArtifact) error
Expand Down
12 changes: 6 additions & 6 deletions pkg/pipeline/WorkflowDagExecutor.go
Original file line number Diff line number Diff line change
Expand Up @@ -923,7 +923,7 @@ func (impl *WorkflowDagExecutorImpl) HandlePreStageSuccessEvent(cdStageCompleteE
return err
}
// Migration of deprecated DataSource Type
if ciArtifact.DataSource == repository.EXT {
if ciArtifact.IsMigrationRequired() {
migrationErr := impl.ciArtifactRepository.MigrateToWebHookDataSourceType(ciArtifact.Id)
if migrationErr != nil {
impl.logger.Warnw("unable to migrate deprecated DataSource", "artifactId", ciArtifact.Id)
Expand Down Expand Up @@ -1270,7 +1270,7 @@ func (impl *WorkflowDagExecutorImpl) TriggerPostStage(cdWf *pipelineConfig.CdWor
}
}
// Migration of deprecated DataSource Type
if cdWf.CiArtifact.DataSource == repository.EXT {
if cdWf.CiArtifact.IsMigrationRequired() {
migrationErr := impl.ciArtifactRepository.MigrateToWebHookDataSourceType(cdWf.CiArtifact.Id)
if migrationErr != nil {
impl.logger.Warnw("unable to migrate deprecated DataSource", "artifactId", cdWf.CiArtifact.Id)
Expand Down Expand Up @@ -1441,7 +1441,7 @@ func (impl *WorkflowDagExecutorImpl) buildWFRequest(runner *pipelineConfig.CdWor
return nil, err
}
// Migration of deprecated DataSource Type
if artifact.DataSource == repository.EXT {
if artifact.IsMigrationRequired() {
migrationErr := impl.ciArtifactRepository.MigrateToWebHookDataSourceType(artifact.Id)
if migrationErr != nil {
impl.logger.Warnw("unable to migrate deprecated DataSource", "artifactId", artifact.Id)
Expand Down Expand Up @@ -2311,7 +2311,7 @@ func (impl *WorkflowDagExecutorImpl) ManualCdTrigger(overrideRequest *bean.Value
return 0, err
}
// Migration of deprecated DataSource Type
if artifact.DataSource == repository.EXT {
if artifact.IsMigrationRequired() {
migrationErr := impl.ciArtifactRepository.MigrateToWebHookDataSourceType(artifact.Id)
if migrationErr != nil {
impl.logger.Warnw("unable to migrate deprecated DataSource", "artifactId", artifact.Id)
Expand Down Expand Up @@ -2390,7 +2390,7 @@ func (impl *WorkflowDagExecutorImpl) ManualCdTrigger(overrideRequest *bean.Value
return 0, err
}
// Migration of deprecated DataSource Type
if artifact.DataSource == repository.EXT {
if artifact.IsMigrationRequired() {
Ash-exp marked this conversation as resolved.
Show resolved Hide resolved
migrationErr := impl.ciArtifactRepository.MigrateToWebHookDataSourceType(artifact.Id)
if migrationErr != nil {
impl.logger.Warnw("unable to migrate deprecated DataSource", "artifactId", artifact.Id)
Expand Down Expand Up @@ -2625,7 +2625,7 @@ func (impl *WorkflowDagExecutorImpl) subscribeTriggerBulkAction() error {
return
}
// Migration of deprecated DataSource Type
if artifact.DataSource == repository.EXT {
if artifact.IsMigrationRequired() {
migrationErr := impl.ciArtifactRepository.MigrateToWebHookDataSourceType(artifact.Id)
if migrationErr != nil {
impl.logger.Warnw("unable to migrate deprecated DataSource", "artifactId", artifact.Id)
Expand Down