Skip to content

Commit

Permalink
Revert "refactored few type objects"
Browse files Browse the repository at this point in the history
This reverts commit 7d1c6fa.
  • Loading branch information
pghildiyal committed Oct 29, 2023
1 parent 7d1c6fa commit 926a986
Show file tree
Hide file tree
Showing 20 changed files with 624 additions and 659 deletions.
3 changes: 1 addition & 2 deletions Wire.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ import (
history3 "github.com/devtron-labs/devtron/pkg/pipeline/history"
repository3 "github.com/devtron-labs/devtron/pkg/pipeline/history/repository"
repository5 "github.com/devtron-labs/devtron/pkg/pipeline/repository"
"github.com/devtron-labs/devtron/pkg/pipeline/types"
"github.com/devtron-labs/devtron/pkg/plugin"
repository6 "github.com/devtron-labs/devtron/pkg/plugin/repository"
"github.com/devtron-labs/devtron/pkg/projectManagementService/jira"
Expand Down Expand Up @@ -442,7 +441,7 @@ func InitializeApp() (*App, error) {
repository.NewNotificationSettingsRepositoryImpl,
wire.Bind(new(repository.NotificationSettingsRepository), new(*repository.NotificationSettingsRepositoryImpl)),
util.IntValidator,
types.GetCiCdConfig,
pipeline.GetCiCdConfig,

pipeline.NewWorkflowServiceImpl,
wire.Bind(new(pipeline.WorkflowService), new(*pipeline.WorkflowServiceImpl)),
Expand Down
6 changes: 3 additions & 3 deletions api/restHandler/PubSubClientRestHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ package restHandler

import (
"encoding/json"
"github.com/devtron-labs/devtron/pkg/pipeline/types"
"net/http"
"strings"

pubsub "github.com/devtron-labs/common-lib/pubsub-lib"
"github.com/devtron-labs/devtron/api/restHandler/common"
"github.com/devtron-labs/devtron/pkg/pipeline"
"go.uber.org/zap"
)

Expand All @@ -35,15 +35,15 @@ type PubSubClientRestHandler interface {
type PubSubClientRestHandlerImpl struct {
pubsubClient *pubsub.PubSubClientServiceImpl
logger *zap.SugaredLogger
cdConfig *types.CiCdConfig
cdConfig *pipeline.CiCdConfig
}

type PublishRequest struct {
Topic string `json:"topic"`
Payload json.RawMessage `json:"payload"`
}

func NewPubSubClientRestHandlerImpl(pubsubClient *pubsub.PubSubClientServiceImpl, logger *zap.SugaredLogger, cdConfig *types.CiCdConfig) *PubSubClientRestHandlerImpl {
func NewPubSubClientRestHandlerImpl(pubsubClient *pubsub.PubSubClientServiceImpl, logger *zap.SugaredLogger, cdConfig *pipeline.CiCdConfig) *PubSubClientRestHandlerImpl {
return &PubSubClientRestHandlerImpl{
pubsubClient: pubsubClient,
logger: logger,
Expand Down
5 changes: 2 additions & 3 deletions pkg/pipeline/ArgoWorkflowExecutor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
bean2 "github.com/devtron-labs/devtron/api/bean"
"github.com/devtron-labs/devtron/internal/util"
"github.com/devtron-labs/devtron/pkg/pipeline/bean"
"github.com/devtron-labs/devtron/pkg/pipeline/types"
"github.com/stretchr/testify/assert"
v12 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand All @@ -28,7 +27,7 @@ func TestExecuteWorkflow(t *testing.T) {
t.SkipNow()
logger, loggerErr := util.NewSugardLogger()
assert.Nil(t, loggerErr)
cdConfig, err := types.GetCiCdConfig()
cdConfig, err := GetCiCdConfig()
assert.Nil(t, err)
workflowExecutorImpl := NewArgoWorkflowExecutorImpl(logger)

Expand Down Expand Up @@ -261,7 +260,7 @@ func getGcpBlobStorage() *blob_storage.GcpBlobConfig {
}
}

func getBaseWorkflowTemplate(cdConfig *types.CiCdConfig) bean.WorkflowTemplate {
func getBaseWorkflowTemplate(cdConfig *CiCdConfig) bean.WorkflowTemplate {

workflowTemplate := bean.WorkflowTemplate{}
workflowTemplate.WfControllerInstanceID = "random-controller-id"
Expand Down
17 changes: 8 additions & 9 deletions pkg/pipeline/BuildPipelineConfigService.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import (
"github.com/devtron-labs/devtron/pkg/bean"
bean3 "github.com/devtron-labs/devtron/pkg/pipeline/bean"
"github.com/devtron-labs/devtron/pkg/pipeline/history"
"github.com/devtron-labs/devtron/pkg/pipeline/types"
resourceGroup2 "github.com/devtron-labs/devtron/pkg/resourceGroup"
"github.com/devtron-labs/devtron/pkg/sql"
util2 "github.com/devtron-labs/devtron/util"
Expand Down Expand Up @@ -110,7 +109,7 @@ type CiPipelineConfigServiceImpl struct {
ciTemplateService CiTemplateService
materialRepo pipelineConfig.MaterialRepository
ciPipelineRepository pipelineConfig.CiPipelineRepository
ciConfig *types.CiCdConfig
ciConfig *CiCdConfig
attributesService attributes.AttributesService
ciWorkflowRepository pipelineConfig.CiWorkflowRepository
appWorkflowRepository appWorkflow.AppWorkflowRepository
Expand Down Expand Up @@ -138,7 +137,7 @@ func NewCiPipelineConfigServiceImpl(logger *zap.SugaredLogger,
ciPipelineRepository pipelineConfig.CiPipelineRepository,
ecrConfig *EcrConfig,
appWorkflowRepository appWorkflow.AppWorkflowRepository,
ciConfig *types.CiCdConfig,
ciConfig *CiCdConfig,
attributesService attributes.AttributesService,
pipelineStageService PipelineStageService,
ciPipelineMaterialRepository pipelineConfig.CiPipelineMaterialRepository,
Expand Down Expand Up @@ -544,7 +543,7 @@ func (impl *CiPipelineConfigServiceImpl) GetCiPipeline(appId int) (ciConfig *bea
return nil, err
}
if hostUrl != nil {
impl.ciConfig.ExternalCiWebhookUrl = fmt.Sprintf("%s/%s", hostUrl.Value, types.ExternalCiWebhookPath)
impl.ciConfig.ExternalCiWebhookUrl = fmt.Sprintf("%s/%s", hostUrl.Value, ExternalCiWebhookPath)
}
}
//map of ciPipelineId and their templateOverrideConfig
Expand Down Expand Up @@ -706,7 +705,7 @@ func (impl *CiPipelineConfigServiceImpl) GetCiPipelineById(pipelineId int) (ciPi
return nil, err
}
if hostUrl != nil {
impl.ciConfig.ExternalCiWebhookUrl = fmt.Sprintf("%s/%s", hostUrl.Value, types.ExternalCiWebhookPath)
impl.ciConfig.ExternalCiWebhookUrl = fmt.Sprintf("%s/%s", hostUrl.Value, ExternalCiWebhookPath)
}
}

Expand Down Expand Up @@ -934,7 +933,7 @@ func (impl *CiPipelineConfigServiceImpl) GetExternalCi(appId int) (ciConfig []*b
return nil, err
}
if hostUrl != nil {
impl.ciConfig.ExternalCiWebhookUrl = fmt.Sprintf("%s/%s", hostUrl.Value, types.ExternalCiWebhookPath)
impl.ciConfig.ExternalCiWebhookUrl = fmt.Sprintf("%s/%s", hostUrl.Value, ExternalCiWebhookPath)
}

externalCiConfigs := make([]*bean.ExternalCiConfig, 0)
Expand Down Expand Up @@ -1066,7 +1065,7 @@ func (impl *CiPipelineConfigServiceImpl) GetExternalCiById(appId int, externalCi
return nil, err
}
if hostUrl != nil {
impl.ciConfig.ExternalCiWebhookUrl = fmt.Sprintf("%s/%s", hostUrl.Value, types.ExternalCiWebhookPath)
impl.ciConfig.ExternalCiWebhookUrl = fmt.Sprintf("%s/%s", hostUrl.Value, ExternalCiWebhookPath)
}

appWorkflowMappings, err := impl.appWorkflowRepository.FindWFCDMappingByExternalCiId(externalCiPipeline.Id)
Expand Down Expand Up @@ -1605,7 +1604,7 @@ func (impl *CiPipelineConfigServiceImpl) GetCiPipelineByEnvironment(request reso
return nil, err
}
if hostUrl != nil {
impl.ciConfig.ExternalCiWebhookUrl = fmt.Sprintf("%s/%s", hostUrl.Value, types.ExternalCiWebhookPath)
impl.ciConfig.ExternalCiWebhookUrl = fmt.Sprintf("%s/%s", hostUrl.Value, ExternalCiWebhookPath)
}
}

Expand Down Expand Up @@ -1892,7 +1891,7 @@ func (impl *CiPipelineConfigServiceImpl) GetExternalCiByEnvironment(request reso
return nil, err
}
if hostUrl != nil {
impl.ciConfig.ExternalCiWebhookUrl = fmt.Sprintf("%s/%s", hostUrl.Value, types.ExternalCiWebhookPath)
impl.ciConfig.ExternalCiWebhookUrl = fmt.Sprintf("%s/%s", hostUrl.Value, ExternalCiWebhookPath)
}

var externalCiPipelineIds []int
Expand Down
17 changes: 8 additions & 9 deletions pkg/pipeline/CdHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ import (
"github.com/devtron-labs/devtron/pkg/cluster"
repository2 "github.com/devtron-labs/devtron/pkg/cluster/repository"
bean2 "github.com/devtron-labs/devtron/pkg/pipeline/bean"
"github.com/devtron-labs/devtron/pkg/pipeline/types"
resourceGroup2 "github.com/devtron-labs/devtron/pkg/resourceGroup"
"github.com/devtron-labs/devtron/pkg/sql"
"github.com/devtron-labs/devtron/pkg/user"
Expand Down Expand Up @@ -119,7 +118,7 @@ type CdHandlerImpl struct {
imageTaggingService ImageTaggingService
k8sUtil *k8s.K8sUtil
workflowService WorkflowService
config *types.CdConfig
config *CdConfig
}

func NewCdHandlerImpl(Logger *zap.SugaredLogger, userService user.UserService, cdWorkflowRepository pipelineConfig.CdWorkflowRepository, ciLogService CiLogService, ciArtifactRepository repository.CiArtifactRepository, ciPipelineMaterialRepository pipelineConfig.CiPipelineMaterialRepository, pipelineRepository pipelineConfig.PipelineRepository, envRepository repository2.EnvironmentRepository, ciWorkflowRepository pipelineConfig.CiWorkflowRepository, helmAppService client.HelmAppService, pipelineOverrideRepository chartConfig.PipelineOverrideRepository, workflowDagExecutor WorkflowDagExecutor, appListingService app.AppListingService, appListingRepository repository.AppListingRepository, pipelineStatusTimelineRepository pipelineConfig.PipelineStatusTimelineRepository, application application.ServiceClient, argoUserService argo.ArgoUserService, deploymentEventHandler app.DeploymentEventHandler, eventClient client2.EventClient, pipelineStatusTimelineResourcesService status.PipelineStatusTimelineResourcesService, pipelineStatusSyncDetailService status.PipelineStatusSyncDetailService, pipelineStatusTimelineService status.PipelineStatusTimelineService, appService app.AppService, appStatusService app_status.AppStatusService, enforcerUtil rbac.EnforcerUtil, installedAppRepository repository3.InstalledAppRepository, installedAppVersionHistoryRepository repository3.InstalledAppVersionHistoryRepository, appRepository app2.AppRepository, resourceGroupService resourceGroup2.ResourceGroupService, imageTaggingService ImageTaggingService, k8sUtil *k8s.K8sUtil, workflowService WorkflowService) *CdHandlerImpl {
Expand Down Expand Up @@ -157,7 +156,7 @@ func NewCdHandlerImpl(Logger *zap.SugaredLogger, userService user.UserService, c
k8sUtil: k8sUtil,
workflowService: workflowService,
}
config, err := types.GetCdConfig()
config, err := GetCdConfig()
if err != nil {
return nil
}
Expand Down Expand Up @@ -597,9 +596,9 @@ func (impl *CdHandlerImpl) CancelStage(workflowRunnerId int, userId int32) (int,
return 0, err
}
var isExtCluster bool
if workflowRunner.WorkflowType == types.PRE {
if workflowRunner.WorkflowType == PRE {
isExtCluster = pipeline.RunPreStageInEnv
} else if workflowRunner.WorkflowType == types.POST {
} else if workflowRunner.WorkflowType == POST {
isExtCluster = pipeline.RunPostStageInEnv
}
var restConfig *rest.Config
Expand Down Expand Up @@ -894,9 +893,9 @@ func (impl *CdHandlerImpl) GetRunningWorkflowLogs(environmentId int, pipelineId
return nil, nil, err
}
var isExtCluster bool
if cdWorkflow.WorkflowType == types.PRE {
if cdWorkflow.WorkflowType == PRE {
isExtCluster = pipeline.RunPreStageInEnv
} else if cdWorkflow.WorkflowType == types.POST {
} else if cdWorkflow.WorkflowType == POST {
isExtCluster = pipeline.RunPostStageInEnv
}
return impl.getWorkflowLogs(pipelineId, cdWorkflow, clusterConfig, isExtCluster)
Expand Down Expand Up @@ -946,7 +945,7 @@ func (impl *CdHandlerImpl) getLogsFromRepository(pipelineId int, cdWorkflow *pip
LogsFilePath: cdWorkflow.LogLocation, // impl.ciCdConfig.CiDefaultBuildLogsKeyPrefix + "/" + cdWorkflow.Name + "/main.log", //TODO - fixme
CloudProvider: impl.config.CloudProvider,
AzureBlobConfig: &blob_storage.AzureBlobBaseConfig{
Enabled: impl.config.CloudProvider == types.BLOB_STORAGE_AZURE,
Enabled: impl.config.CloudProvider == BLOB_STORAGE_AZURE,
AccountName: impl.config.AzureAccountName,
BlobContainerName: impl.config.AzureBlobContainerCiLog,
AccountKey: impl.config.AzureAccountKey,
Expand Down Expand Up @@ -1095,7 +1094,7 @@ func (impl *CdHandlerImpl) DownloadCdWorkflowArtifacts(pipelineId int, buildId i
VersioningEnabled: impl.config.BlobStorageS3BucketVersioned,
}
azureBlobBaseConfig := &blob_storage.AzureBlobBaseConfig{
Enabled: impl.config.CloudProvider == types.BLOB_STORAGE_AZURE,
Enabled: impl.config.CloudProvider == BLOB_STORAGE_AZURE,
AccountKey: impl.config.AzureAccountKey,
AccountName: impl.config.AzureAccountName,
BlobContainerName: impl.config.AzureBlobContainerCiLog,
Expand Down
12 changes: 2 additions & 10 deletions pkg/pipeline/types/CiCdConfig.go → pkg/pipeline/CiCdConfig.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package types
package pipeline

import (
"encoding/json"
Expand Down Expand Up @@ -191,7 +191,7 @@ func GetCiCdConfig() (*CiCdConfig, error) {
return cfg, err
}

func GetNodeLabel(cfg *CiCdConfig, pipelineType bean.WorkflowPipelineType, isExt bool) (map[string]string, error) {
func getNodeLabel(cfg *CiCdConfig, pipelineType bean.WorkflowPipelineType, isExt bool) (map[string]string, error) {
node := []string{}
if pipelineType == bean.CI_WORKFLOW_PIPELINE_TYPE || pipelineType == bean.JOB_WORKFLOW_PIPELINE_TYPE {
node = cfg.CiNodeLabelSelector
Expand Down Expand Up @@ -464,11 +464,3 @@ func getWorkflowVolumeMounts(volumeMountForCi CiVolumeMount) v12.VolumeMount {
MountPath: volumeMountForCi.ContainerMountPath,
}
}

const BLOB_STORAGE_AZURE = "AZURE"

const BLOB_STORAGE_S3 = "S3"

const BLOB_STORAGE_GCP = "GCP"

const BLOB_STORAGE_MINIO = "MINIO"
7 changes: 3 additions & 4 deletions pkg/pipeline/CiCdPipelineOrchestrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ import (
history3 "github.com/devtron-labs/devtron/pkg/pipeline/history"
repository4 "github.com/devtron-labs/devtron/pkg/pipeline/history/repository"
repository5 "github.com/devtron-labs/devtron/pkg/pipeline/repository"
"github.com/devtron-labs/devtron/pkg/pipeline/types"
"github.com/devtron-labs/devtron/pkg/sql"
"github.com/devtron-labs/devtron/pkg/user"
bean3 "github.com/devtron-labs/devtron/pkg/user/bean"
Expand Down Expand Up @@ -97,7 +96,7 @@ type CiCdPipelineOrchestratorImpl struct {
ciPipelineRepository pipelineConfig.CiPipelineRepository
ciPipelineMaterialRepository pipelineConfig.CiPipelineMaterialRepository
GitSensorClient gitSensor.Client
ciConfig *types.CiCdConfig
ciConfig *CiCdConfig
appWorkflowRepository appWorkflow.AppWorkflowRepository
envRepository repository2.EnvironmentRepository
attributesService attributes.AttributesService
Expand Down Expand Up @@ -125,7 +124,7 @@ func NewCiCdPipelineOrchestrator(
pipelineRepository pipelineConfig.PipelineRepository,
ciPipelineRepository pipelineConfig.CiPipelineRepository,
ciPipelineMaterialRepository pipelineConfig.CiPipelineMaterialRepository,
GitSensorClient gitSensor.Client, ciConfig *types.CiCdConfig,
GitSensorClient gitSensor.Client, ciConfig *CiCdConfig,
appWorkflowRepository appWorkflow.AppWorkflowRepository,
envRepository repository2.EnvironmentRepository,
attributesService attributes.AttributesService,
Expand Down Expand Up @@ -995,7 +994,7 @@ func (impl CiCdPipelineOrchestratorImpl) generateExternalCiPayload(ciPipeline *b
return nil
}
if hostUrl != nil {
impl.ciConfig.ExternalCiWebhookUrl = fmt.Sprintf("%s/%s", hostUrl.Value, types.ExternalCiWebhookPath)
impl.ciConfig.ExternalCiWebhookUrl = fmt.Sprintf("%s/%s", hostUrl.Value, ExternalCiWebhookPath)
}
}
accessKey := keyPrefix + "." + apiKey
Expand Down
3 changes: 1 addition & 2 deletions pkg/pipeline/CiCdPipelineOrchestrator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
repository3 "github.com/devtron-labs/devtron/pkg/cluster/repository"
"github.com/devtron-labs/devtron/pkg/pipeline/history"
repository4 "github.com/devtron-labs/devtron/pkg/pipeline/history/repository"
"github.com/devtron-labs/devtron/pkg/pipeline/types"
"github.com/devtron-labs/devtron/pkg/user"
"github.com/stretchr/testify/assert"
"log"
Expand Down Expand Up @@ -136,7 +135,7 @@ func InitClusterNoteService() {
ciPipelineHistoryRepository := repository4.NewCiPipelineHistoryRepositoryImpl(conn, logger)
ciPipelineMaterialRepository := pipelineConfig.NewCiPipelineMaterialRepositoryImpl(conn, logger)
GitSensorClient, err := gitSensor.NewGitSensorClient(logger, &gitSensor.ClientConfig{})
ciConfig := &types.CiCdConfig{}
ciConfig := &CiCdConfig{}
appWorkflowRepository := appWorkflow.NewAppWorkflowRepositoryImpl(logger, conn)
envRepository := repository3.NewEnvironmentRepositoryImpl(conn, logger, nil)
attributesService := attributes.NewAttributesServiceImpl(logger, nil)
Expand Down
11 changes: 5 additions & 6 deletions pkg/pipeline/CiHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import (
repository3 "github.com/devtron-labs/devtron/pkg/cluster/repository"
k8s2 "github.com/devtron-labs/devtron/pkg/k8s"
bean3 "github.com/devtron-labs/devtron/pkg/pipeline/bean"
"github.com/devtron-labs/devtron/pkg/pipeline/types"
resourceGroup "github.com/devtron-labs/devtron/pkg/resourceGroup"
"github.com/devtron-labs/devtron/util/rbac"
"io/ioutil"
Expand Down Expand Up @@ -109,7 +108,7 @@ type CiHandlerImpl struct {
imageTaggingService ImageTaggingService
customTagService CustomTagService
appWorkflowRepository appWorkflow.AppWorkflowRepository
config *types.CiConfig
config *CiConfig
k8sCommonService k8s2.K8sCommonService
}

Expand Down Expand Up @@ -138,7 +137,7 @@ func NewCiHandlerImpl(Logger *zap.SugaredLogger, ciService CiService, ciPipeline
appWorkflowRepository: appWorkflowRepository,
k8sCommonService: k8sCommonService,
}
config, err := types.GetCiConfig()
config, err := GetCiConfig()
if err != nil {
return nil
}
Expand Down Expand Up @@ -863,7 +862,7 @@ func (impl *CiHandlerImpl) getLogsFromRepository(pipelineId int, ciWorkflow *pip
LogsFilePath: logsFilePath,
CloudProvider: impl.config.CloudProvider,
AzureBlobConfig: &blob_storage.AzureBlobBaseConfig{
Enabled: impl.config.CloudProvider == types.BLOB_STORAGE_AZURE,
Enabled: impl.config.CloudProvider == BLOB_STORAGE_AZURE,
AccountName: impl.config.AzureAccountName,
BlobContainerName: impl.config.AzureBlobContainerCiLog,
AccountKey: impl.config.AzureAccountKey,
Expand Down Expand Up @@ -922,7 +921,7 @@ func (impl *CiHandlerImpl) DownloadCiWorkflowArtifacts(pipelineId int, buildId i
ciConfig.CiCacheRegion = impl.config.DefaultCacheBucketRegion
}
azureBlobConfig := &blob_storage.AzureBlobBaseConfig{
Enabled: impl.config.CloudProvider == types.BLOB_STORAGE_AZURE,
Enabled: impl.config.CloudProvider == BLOB_STORAGE_AZURE,
AccountName: impl.config.AzureAccountName,
BlobContainerName: impl.config.AzureBlobContainerCiLog,
AccountKey: impl.config.AzureAccountKey,
Expand Down Expand Up @@ -994,7 +993,7 @@ func (impl *CiHandlerImpl) GetHistoricBuildLogs(pipelineId int, workflowId int,
LogsFilePath: ciWorkflow.LogLocation,
CloudProvider: impl.config.CloudProvider,
AzureBlobConfig: &blob_storage.AzureBlobBaseConfig{
Enabled: impl.config.CloudProvider == types.BLOB_STORAGE_AZURE,
Enabled: impl.config.CloudProvider == BLOB_STORAGE_AZURE,
AccountName: impl.config.AzureAccountName,
BlobContainerName: impl.config.AzureBlobContainerCiLog,
AccountKey: impl.config.AzureAccountKey,
Expand Down
Loading

0 comments on commit 926a986

Please sign in to comment.