Skip to content

Commit 7e7928d

Browse files
committed
common constants create
1 parent 237d8d0 commit 7e7928d

File tree

7 files changed

+18
-52
lines changed

7 files changed

+18
-52
lines changed

internal/sql/repository/pipelineConfig/CiPipelineRepository.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ import (
2121
"fmt"
2222
"github.com/devtron-labs/devtron/internal/sql/repository/app"
2323
"github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig/bean/ciPipeline"
24+
buildCommonBean "github.com/devtron-labs/devtron/pkg/build/pipeline/bean/common"
2425
repository2 "github.com/devtron-labs/devtron/pkg/cluster/environment/repository"
25-
"github.com/devtron-labs/devtron/pkg/pipeline/constants"
2626
"github.com/devtron-labs/devtron/pkg/sql"
2727
"github.com/devtron-labs/devtron/util/response/pagination"
2828
"github.com/go-pg/pg"
@@ -641,7 +641,7 @@ func (impl *CiPipelineRepositoryImpl) FindLinkedCiCount(ciPipelineId int) (int,
641641
pipeline := &CiPipeline{}
642642
cnt, err := impl.dbConnection.Model(pipeline).
643643
Where("parent_ci_pipeline = ?", ciPipelineId).
644-
Where("ci_pipeline_type != ?", constants.LINKED_CD).
644+
Where("ci_pipeline_type != ?", buildCommonBean.LINKED_CD).
645645
Where("deleted = ?", false).
646646
Count()
647647
if err == pg.ErrNoRows {
@@ -656,7 +656,7 @@ func (impl *CiPipelineRepositoryImpl) GetLinkedCiPipelines(ctx context.Context,
656656
var linkedCIPipelines []*CiPipeline
657657
err := impl.dbConnection.Model(&linkedCIPipelines).
658658
Where("parent_ci_pipeline = ?", ciPipelineId).
659-
Where("ci_pipeline_type != ?", constants.LINKED_CD).
659+
Where("ci_pipeline_type != ?", buildCommonBean.LINKED_CD).
660660
Where("deleted = ?", false).
661661
Select()
662662
if err != nil {
@@ -694,7 +694,7 @@ func (impl *CiPipelineRepositoryImpl) GetDownStreamInfo(ctx context.Context, sou
694694
JoinOn("e.active = ?", true).
695695
// constrains
696696
Where("ci_pipeline.parent_ci_pipeline = ?", sourceCiPipelineId).
697-
Where("ci_pipeline.ci_pipeline_type != ?", constants.LINKED_CD).
697+
Where("ci_pipeline.ci_pipeline_type != ?", buildCommonBean.LINKED_CD).
698698
Where("ci_pipeline.deleted = ?", false)
699699
// app name filtering with lower case
700700
if len(appNameMatch) != 0 {

pkg/app/AppListingService.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ import (
2525
"github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig/bean/workflow/cdWorkflow"
2626
read4 "github.com/devtron-labs/devtron/pkg/app/appDetails/read"
2727
userrepository "github.com/devtron-labs/devtron/pkg/auth/user/repository"
28+
buildCommonBean "github.com/devtron-labs/devtron/pkg/build/pipeline/bean/common"
2829
ciConfig "github.com/devtron-labs/devtron/pkg/build/pipeline/read"
2930
chartRepoRepository "github.com/devtron-labs/devtron/pkg/chartRepo/repository"
3031
repository2 "github.com/devtron-labs/devtron/pkg/cluster/environment/repository"
3132
"github.com/devtron-labs/devtron/pkg/deployment/manifest/deployedAppMetrics"
3233
"github.com/devtron-labs/devtron/pkg/deployment/manifest/deploymentTemplate/read"
3334
"github.com/devtron-labs/devtron/pkg/dockerRegistry"
34-
"github.com/devtron-labs/devtron/pkg/pipeline/constants"
3535
errors2 "github.com/juju/errors"
3636
"go.opentelemetry.io/otel"
3737
"golang.org/x/exp/slices"
@@ -607,7 +607,7 @@ func (impl AppListingServiceImpl) setIpAccessProvidedData(ctx context.Context, a
607607
}
608608

609609
if ciPipeline != nil && ciPipeline.CiTemplate != nil && len(*ciPipeline.CiTemplate.DockerRegistryId) > 0 {
610-
if !ciPipeline.IsExternal || ciPipeline.ParentCiPipeline != 0 && ciPipeline.PipelineType != string(constants.LINKED_CD) {
610+
if !ciPipeline.IsExternal || ciPipeline.ParentCiPipeline != 0 && ciPipeline.PipelineType != string(buildCommonBean.LINKED_CD) {
611611
appDetailContainer.IsExternalCi = false
612612
}
613613
// get dockerRegistryId starts

pkg/deployment/trigger/devtronApps/PreStageTriggerService.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import (
3535
bean7 "github.com/devtron-labs/devtron/pkg/auth/user/bean"
3636
bean4 "github.com/devtron-labs/devtron/pkg/bean"
3737
"github.com/devtron-labs/devtron/pkg/bean/common"
38+
buildCommonBean "github.com/devtron-labs/devtron/pkg/build/pipeline/bean/common"
3839
repository4 "github.com/devtron-labs/devtron/pkg/cluster/environment/repository"
3940
bean5 "github.com/devtron-labs/devtron/pkg/deployment/common/bean"
4041
adapter2 "github.com/devtron-labs/devtron/pkg/deployment/trigger/devtronApps/adapter"
@@ -43,7 +44,6 @@ import (
4344
"github.com/devtron-labs/devtron/pkg/pipeline"
4445
"github.com/devtron-labs/devtron/pkg/pipeline/adapter"
4546
pipelineConfigBean "github.com/devtron-labs/devtron/pkg/pipeline/bean"
46-
"github.com/devtron-labs/devtron/pkg/pipeline/constants"
4747
repository3 "github.com/devtron-labs/devtron/pkg/pipeline/history/repository"
4848
"github.com/devtron-labs/devtron/pkg/pipeline/types"
4949
"github.com/devtron-labs/devtron/pkg/plugin"
@@ -532,7 +532,7 @@ func (impl *TriggerServiceImpl) buildWFRequest(runner *pipelineConfig.CdWorkflow
532532
return nil, err
533533
}
534534
ciProjectDetail.CommitTime = commitTime.Format(bean4.LayoutRFC3339)
535-
} else if ciPipeline.PipelineType == string(constants.CI_JOB) {
535+
} else if ciPipeline.PipelineType == string(buildCommonBean.CI_JOB) {
536536
// This has been done to resolve unmarshalling issue in ci-runner, in case of no commit time(eg- polling container images)
537537
ciProjectDetail.CommitTime = time.Time{}.Format(bean4.LayoutRFC3339)
538538
} else {

pkg/pipeline/CiCdPipelineOrchestrator.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,12 @@ import (
3232
repository6 "github.com/devtron-labs/devtron/pkg/build/git/gitMaterial/repository"
3333
"github.com/devtron-labs/devtron/pkg/build/pipeline"
3434
bean2 "github.com/devtron-labs/devtron/pkg/build/pipeline/bean"
35-
common3 "github.com/devtron-labs/devtron/pkg/build/pipeline/bean/common"
35+
buildCommonBean "github.com/devtron-labs/devtron/pkg/build/pipeline/bean/common"
3636
read2 "github.com/devtron-labs/devtron/pkg/chart/read"
3737
repository2 "github.com/devtron-labs/devtron/pkg/cluster/environment/repository"
3838
"github.com/devtron-labs/devtron/pkg/deployment/common"
3939
"github.com/devtron-labs/devtron/pkg/deployment/common/read"
4040
"github.com/devtron-labs/devtron/pkg/deployment/gitOps/config"
41-
constants3 "github.com/devtron-labs/devtron/pkg/pipeline/constants"
4241
util4 "github.com/devtron-labs/devtron/pkg/pipeline/util"
4342
"github.com/devtron-labs/devtron/pkg/plugin"
4443
"github.com/devtron-labs/devtron/util/beHelper"
@@ -330,7 +329,7 @@ func (impl CiCdPipelineOrchestratorImpl) validateCiPipelineMaterial(ciPipelineMa
330329

331330
func (impl CiCdPipelineOrchestratorImpl) getSkipMessage(ciPipeline *pipelineConfig.CiPipeline) string {
332331
switch ciPipeline.PipelineType {
333-
case string(common3.LINKED_CD):
332+
case string(buildCommonBean.LINKED_CD):
334333
return "“Sync with Environment”"
335334
default:
336335
return "“Linked Build Pipeline”"
@@ -1011,7 +1010,7 @@ func (impl CiCdPipelineOrchestratorImpl) CreateCiConf(createRequest *bean.CiConf
10111010

10121011
var pipelineMaterials []*pipelineConfig.CiPipelineMaterial
10131012
for _, r := range ciPipeline.CiMaterial {
1014-
if ciPipeline.PipelineType == common3.LINKED_CD {
1013+
if ciPipeline.PipelineType == buildCommonBean.LINKED_CD {
10151014
continue
10161015
}
10171016
material := &pipelineConfig.CiPipelineMaterial{
@@ -2504,7 +2503,7 @@ func (impl *CiCdPipelineOrchestratorImpl) GetWorkflowCacheConfig(appType helper.
25042503
if appType == helper.Job {
25052504
return util4.GetWorkflowCacheConfig(pipelineWorkflowCacheConfig, impl.workflowCacheConfig.IgnoreJob)
25062505
} else {
2507-
if pipelineType == string(constants3.CI_JOB) {
2506+
if pipelineType == string(buildCommonBean.CI_JOB) {
25082507
return util4.GetWorkflowCacheConfigWithBackwardCompatibility(pipelineWorkflowCacheConfig, impl.ciConfig.WorkflowCacheConfig, impl.workflowCacheConfig.IgnoreCIJob, impl.ciConfig.SkipCiJobBuildCachePushPull)
25092508
} else {
25102509
return util4.GetWorkflowCacheConfigWithBackwardCompatibility(pipelineWorkflowCacheConfig, impl.ciConfig.WorkflowCacheConfig, impl.workflowCacheConfig.IgnoreCI, impl.ciConfig.IgnoreDockerCacheForCI)

pkg/pipeline/CiService.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ import (
3636
common2 "github.com/devtron-labs/devtron/pkg/build/pipeline/bean/common"
3737
repository6 "github.com/devtron-labs/devtron/pkg/cluster/environment/repository"
3838
"github.com/devtron-labs/devtron/pkg/pipeline/adapter"
39-
pipelineConst "github.com/devtron-labs/devtron/pkg/pipeline/constants"
4039
"github.com/devtron-labs/devtron/pkg/pipeline/infraProviders"
4140
"github.com/devtron-labs/devtron/pkg/pipeline/workflowStatus"
4241
bean2 "github.com/devtron-labs/devtron/pkg/plugin/bean"
@@ -195,7 +194,7 @@ func (impl *CiServiceImpl) handleRuntimeParamsValidations(trigger types.Trigger,
195194
}
196195

197196
// checking if user has given run time parameters for externalCiArtifact, if given then sending git material to Ci-Runner
198-
externalCiArtifact, exists := trigger.RuntimeParameters.GetGlobalRuntimeVariables()[pipelineConst.ExtraEnvVarExternalCiArtifactKey]
197+
externalCiArtifact, exists := trigger.RuntimeParameters.GetGlobalRuntimeVariables()[buildBean.ExtraEnvVarExternalCiArtifactKey]
199198
// validate externalCiArtifact as docker image
200199
if exists {
201200
externalCiArtifact = strings.TrimSpace(externalCiArtifact)
@@ -220,11 +219,11 @@ func (impl *CiServiceImpl) handleRuntimeParamsValidations(trigger types.Trigger,
220219

221220
}
222221
// This will overwrite the existing runtime parameters value for constants.externalCiArtifact
223-
trigger.RuntimeParameters = trigger.RuntimeParameters.AddRuntimeGlobalVariable(pipelineConst.ExtraEnvVarExternalCiArtifactKey, externalCiArtifact)
222+
trigger.RuntimeParameters = trigger.RuntimeParameters.AddRuntimeGlobalVariable(buildBean.ExtraEnvVarExternalCiArtifactKey, externalCiArtifact)
224223
var artifactExists bool
225224
var err error
226225

227-
imageDigest, ok := trigger.RuntimeParameters.GetGlobalRuntimeVariables()[pipelineConst.ExtraEnvVarImageDigestKey]
226+
imageDigest, ok := trigger.RuntimeParameters.GetGlobalRuntimeVariables()[buildBean.ExtraEnvVarImageDigestKey]
228227
if !ok || len(imageDigest) == 0 {
229228
artifactExists, err = impl.ciArtifactRepository.IfArtifactExistByImage(externalCiArtifact, trigger.PipelineId)
230229
if err != nil {

pkg/pipeline/constants/constants.go

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,6 @@ package constants
1919
const CDPipelineNotFoundErr = "cd pipeline not found"
2020
const CiPipelineNotFoundErr = "ci pipeline not found"
2121

22-
type PipelineType string
23-
24-
// default PipelineType
25-
const DefaultPipelineType = CI_BUILD
26-
27-
const (
28-
CI_BUILD PipelineType = "CI_BUILD"
29-
LINKED PipelineType = "LINKED"
30-
EXTERNAL PipelineType = "EXTERNAL"
31-
CI_JOB PipelineType = "CI_JOB"
32-
LINKED_CD PipelineType = "LINKED_CD"
33-
)
34-
3522
type PatchPipelineActionResponse string
3623

3724
const (
@@ -43,28 +30,10 @@ const (
4330
PATCH_PIPELINE_ACTION_NOT_APPLICABLE PatchPipelineActionResponse = "N/A"
4431
)
4532

46-
func (r PipelineType) ToString() string {
47-
return string(r)
48-
}
49-
50-
func (pType PipelineType) IsValidPipelineType() bool {
51-
switch pType {
52-
case CI_BUILD, LINKED, EXTERNAL, CI_JOB, LINKED_CD:
53-
return true
54-
default:
55-
return false
56-
}
57-
}
58-
5933
const (
6034
UNIQUE_DEPLOYMENT_APP_NAME = "unique_deployment_app_name"
6135
)
6236

63-
const (
64-
ExtraEnvVarExternalCiArtifactKey = "externalCiArtifact"
65-
ExtraEnvVarImageDigestKey = "imageDigest"
66-
)
67-
6837
const DefaultCiWorkflowNamespace = "devtron-ci"
6938
const Running = "Running"
7039
const Starting = "Starting"

pkg/workflow/dag/WorkflowDagExecutor.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ import (
3838
bean7 "github.com/devtron-labs/devtron/pkg/auth/user/bean"
3939
"github.com/devtron-labs/devtron/pkg/build/artifacts"
4040
bean5 "github.com/devtron-labs/devtron/pkg/build/pipeline/bean"
41-
"github.com/devtron-labs/devtron/pkg/build/pipeline/bean/common"
41+
buildCommonBean "github.com/devtron-labs/devtron/pkg/build/pipeline/bean/common"
4242
common2 "github.com/devtron-labs/devtron/pkg/deployment/common"
4343
"github.com/devtron-labs/devtron/pkg/deployment/manifest"
4444
"github.com/devtron-labs/devtron/pkg/deployment/trigger/devtronApps"
@@ -47,7 +47,6 @@ import (
4747
"github.com/devtron-labs/devtron/pkg/deployment/trigger/devtronApps/userDeploymentRequest/service"
4848
eventProcessorBean "github.com/devtron-labs/devtron/pkg/eventProcessor/bean"
4949
"github.com/devtron-labs/devtron/pkg/pipeline"
50-
constants2 "github.com/devtron-labs/devtron/pkg/pipeline/constants"
5150
repository2 "github.com/devtron-labs/devtron/pkg/plugin/repository"
5251
"github.com/devtron-labs/devtron/pkg/policyGovernance/security/imageScanning"
5352
repository3 "github.com/devtron-labs/devtron/pkg/policyGovernance/security/imageScanning/repository"
@@ -807,7 +806,7 @@ func (impl *WorkflowDagExecutorImpl) HandleCiSuccessEvent(triggerContext trigger
807806

808807
// image scanning plugin can only be applied in Post-ci, scanning in pre-ci doesn't make sense
809808
pipelineStage := repository4.PIPELINE_STAGE_TYPE_POST_CI
810-
if pipelineModal.PipelineType == constants2.CI_JOB.ToString() {
809+
if pipelineModal.PipelineType == buildCommonBean.CI_JOB.ToString() {
811810
pipelineStage = repository4.PIPELINE_STAGE_TYPE_PRE_CI
812811
}
813812
// this flag comes from ci-runner when scanning is enabled from ciPipeline modal
@@ -831,7 +830,7 @@ func (impl *WorkflowDagExecutorImpl) HandleCiSuccessEvent(triggerContext trigger
831830
var pluginArtifacts []*repository.CiArtifact
832831
for registry, artifacts := range request.PluginRegistryArtifactDetails {
833832
for _, image := range artifacts {
834-
if pipelineModal.PipelineType == string(common.CI_JOB) && image == "" {
833+
if pipelineModal.PipelineType == string(buildCommonBean.CI_JOB) && image == "" {
835834
continue
836835
}
837836
pluginArtifact := &repository.CiArtifact{

0 commit comments

Comments
 (0)