Skip to content

Commit

Permalink
updated ArtifactsSourceType const
Browse files Browse the repository at this point in the history
  • Loading branch information
Ash-exp committed Jan 3, 2024
1 parent 9031282 commit 9c9bb11
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 19 deletions.
2 changes: 2 additions & 0 deletions api/router/pubsub/CiEventHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ func (impl *CiEventHandlerImpl) BuildCiArtifactRequest(event CiCompleteEvent) (*
PluginRegistryArtifactDetails: event.PluginRegistryArtifactDetails,
PluginArtifactStage: event.PluginArtifactStage,
}
// if DataSource is empty, repository.WEBHOOK is considered as default
if request.DataSource == "" {
request.DataSource = repository.WEBHOOK
}
Expand Down Expand Up @@ -334,6 +335,7 @@ func (impl *CiEventHandlerImpl) BuildCiArtifactRequestForWebhook(event CiComplet
WorkflowId: event.WorkflowId,
IsArtifactUploaded: event.IsArtifactUploaded,
}
// if DataSource is empty, repository.WEBHOOK is considered as default
if request.DataSource == "" {
request.DataSource = repository.WEBHOOK
}
Expand Down
2 changes: 1 addition & 1 deletion internal/sql/repository/AppListingRepository.go
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ func parseMaterialInfo(materialInfo string, source string) (json.RawMessage, err
fmt.Printf("PARSEMATERIALINFO_MATERIAL_RECOVER, materialInfo: %s, source: %s, err: %s \n", materialInfo, source, r)
}
}()
if source != GOCD && source != CI_RUNNER && source != WEBHOOK && source != DEPRICATED_EXT {
if source != GOCD && source != CI_RUNNER && source != WEBHOOK && source != EXT {
return nil, fmt.Errorf("datasource: %s not supported", source)
}
if materialInfo == "" {
Expand Down
19 changes: 10 additions & 9 deletions internal/sql/repository/CiArtifactRepository.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,14 @@ const (

// List of possible DataSource Type for an artifact
const (
CI_RUNNER ArtifactsSourceType = "CI-RUNNER"
WEBHOOK ArtifactsSourceType = "EXTERNAL" // Currently in use instead of DEPRICATED_EXT
PRE_CD ArtifactsSourceType = "pre_cd"
POST_CD ArtifactsSourceType = "post_cd"
POST_CI ArtifactsSourceType = "post_ci"
GOCD ArtifactsSourceType = "GOCD"
DEPRICATED_EXT ArtifactsSourceType = "ext" // For backward compatibility
CI_RUNNER ArtifactsSourceType = "CI-RUNNER"
WEBHOOK ArtifactsSourceType = "EXTERNAL" // Currently in use instead of EXT
PRE_CD ArtifactsSourceType = "pre_cd"
POST_CD ArtifactsSourceType = "post_cd"
POST_CI ArtifactsSourceType = "post_ci"
GOCD ArtifactsSourceType = "GOCD"
// deprecated; Handled for backward compatibility
EXT ArtifactsSourceType = "ext"
// PRE_CI is not a valid DataSource for an artifact
)

Expand Down Expand Up @@ -495,7 +496,7 @@ func (impl CiArtifactRepositoryImpl) GetArtifactsByCDPipelineAndRunnerType(cdPip

// return map of gitUrl:hash
func (info *CiArtifact) ParseMaterialInfo() (map[string]string, error) {
if info.DataSource != GOCD && info.DataSource != CI_RUNNER && info.DataSource != WEBHOOK && info.DataSource != DEPRICATED_EXT {
if info.DataSource != GOCD && info.DataSource != CI_RUNNER && info.DataSource != WEBHOOK && info.DataSource != EXT {
return nil, fmt.Errorf("datasource: %s not supported", info.DataSource)
}
var ciMaterials []*CiMaterialInfo
Expand Down Expand Up @@ -606,7 +607,7 @@ func (impl CiArtifactRepositoryImpl) GetArtifactsByCDPipelineV2(cdPipelineId int
}

func GetCiMaterialInfo(materialInfo string, source string) ([]CiMaterialInfo, error) {
if source != GOCD && source != CI_RUNNER && source != WEBHOOK && source != POST_CI && source != PRE_CD && source != POST_CD && source != DEPRICATED_EXT {
if source != GOCD && source != CI_RUNNER && source != WEBHOOK && source != POST_CI && source != PRE_CD && source != POST_CD && source != EXT {
return nil, fmt.Errorf("datasource: %s not supported", source)
}
var ciMaterials []CiMaterialInfo
Expand Down
2 changes: 1 addition & 1 deletion pkg/deploymentGroup/DeploymentGroupService.go
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ func (impl *DeploymentGroupServiceImpl) GetArtifactsByCiPipeline(ciPipelineId in
}

func (impl *DeploymentGroupServiceImpl) parseMaterialInfo(materialInfo json.RawMessage, source string) (json.RawMessage, error) {
if source != repository.GOCD && source != repository.CI_RUNNER && source != repository.WEBHOOK && source != repository.DEPRICATED_EXT {
if source != repository.GOCD && source != repository.CI_RUNNER && source != repository.WEBHOOK && source != repository.EXT {
return nil, fmt.Errorf("datasource: %s not supported", source)
}
var ciMaterials []repository.CiMaterialInfo
Expand Down
2 changes: 1 addition & 1 deletion pkg/pipeline/PipelineBuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ type ConfigMapSecretsResponse struct {
}

func parseMaterialInfo(materialInfo json.RawMessage, source string) (json.RawMessage, error) {
if source != repository.GOCD && source != repository.CI_RUNNER && source != repository.WEBHOOK && source != repository.DEPRICATED_EXT && source != repository.PRE_CD && source != repository.POST_CD && source != repository.POST_CI {
if source != repository.GOCD && source != repository.CI_RUNNER && source != repository.WEBHOOK && source != repository.EXT && source != repository.PRE_CD && source != repository.POST_CD && source != repository.POST_CI {
return nil, fmt.Errorf("datasource: %s not supported", source)
}
var ciMaterials []repository.CiMaterialInfo
Expand Down
12 changes: 6 additions & 6 deletions pkg/pipeline/WorkflowDagExecutor.go
Original file line number Diff line number Diff line change
Expand Up @@ -920,7 +920,7 @@ func (impl *WorkflowDagExecutorImpl) HandlePreStageSuccessEvent(cdStageCompleteE
return err
}
// Migration of deprecated DataSource Type
if ciArtifact.DataSource == repository.DEPRICATED_EXT {
if ciArtifact.DataSource == repository.EXT {
migrationErr := impl.ciArtifactRepository.MigrateToWebHookDataSourceType(ciArtifact.Id)
if migrationErr != nil {
impl.logger.Warnw("unable to migrate deprecated DataSource", "artifactId", ciArtifact.Id)
Expand Down Expand Up @@ -1286,7 +1286,7 @@ func (impl *WorkflowDagExecutorImpl) TriggerPostStage(cdWf *pipelineConfig.CdWor
}
}
// Migration of deprecated DataSource Type
if cdWf.CiArtifact.DataSource == repository.DEPRICATED_EXT {
if cdWf.CiArtifact.DataSource == repository.EXT {
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 @@ -1457,7 +1457,7 @@ func (impl *WorkflowDagExecutorImpl) buildWFRequest(runner *pipelineConfig.CdWor
return nil, err
}
// Migration of deprecated DataSource Type
if artifact.DataSource == repository.DEPRICATED_EXT {
if artifact.DataSource == repository.EXT {
migrationErr := impl.ciArtifactRepository.MigrateToWebHookDataSourceType(artifact.Id)
if migrationErr != nil {
impl.logger.Warnw("unable to migrate deprecated DataSource", "artifactId", artifact.Id)
Expand Down Expand Up @@ -2347,7 +2347,7 @@ func (impl *WorkflowDagExecutorImpl) ManualCdTrigger(overrideRequest *bean.Value
return 0, err
}
// Migration of deprecated DataSource Type
if artifact.DataSource == repository.DEPRICATED_EXT {
if artifact.DataSource == repository.EXT {
migrationErr := impl.ciArtifactRepository.MigrateToWebHookDataSourceType(artifact.Id)
if migrationErr != nil {
impl.logger.Warnw("unable to migrate deprecated DataSource", "artifactId", artifact.Id)
Expand Down Expand Up @@ -2426,7 +2426,7 @@ func (impl *WorkflowDagExecutorImpl) ManualCdTrigger(overrideRequest *bean.Value
return 0, err
}
// Migration of deprecated DataSource Type
if artifact.DataSource == repository.DEPRICATED_EXT {
if artifact.DataSource == repository.EXT {
migrationErr := impl.ciArtifactRepository.MigrateToWebHookDataSourceType(artifact.Id)
if migrationErr != nil {
impl.logger.Warnw("unable to migrate deprecated DataSource", "artifactId", artifact.Id)
Expand Down Expand Up @@ -2661,7 +2661,7 @@ func (impl *WorkflowDagExecutorImpl) subscribeTriggerBulkAction() error {
return
}
// Migration of deprecated DataSource Type
if artifact.DataSource == repository.DEPRICATED_EXT {
if artifact.DataSource == repository.EXT {
migrationErr := impl.ciArtifactRepository.MigrateToWebHookDataSourceType(artifact.Id)
if migrationErr != nil {
impl.logger.Warnw("unable to migrate deprecated DataSource", "artifactId", artifact.Id)
Expand Down
2 changes: 1 addition & 1 deletion wire_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9c9bb11

Please sign in to comment.